Tuesday, December 18, 2007

JAVA 2.0 NOTE



7. Input/Output in Java



Input

int read( ) throws IOException

final String readLine( ) throws IOException

int n = System.out.read( );

String str = inData.readLine( );

Here DataInputStream inData = new DataInputStream (System.in);

Output

System.out.println( );

System.out.print( );

System.out.write (int byte); - console output

Reading and Writing files

It throws IOException

FileInputStream fin = new FileInputStream(filename);

int fin.read( ) - to read a char from a file

void fin.close( ) - to close a file

FileOutputStream fout = new FileOutputStream(filename);

void fout.write(int I);

fout.close( );

String Methods :
String s = new String( );

char chars[ ] { ‘a’, ‘b’, ‘c’);

String s1 new String(chars);

Int s.length( )

boolean s.equals(s1)

String s.substring(int,int) ;

char s.charAt(int);

String toString(object);

String s.replace(char,char);

String s.trim( );

String s.toLowerCase( );

String s.toUpperCase( );






No comments: