To read a file:

BufferedReader reader = new BufferedReader(new FileReader("file1"));
reader.read(buffer);

To write:

BufferedWriter writer = new BufferedWriter(new FileWriter("file1"));
writer.write(str);


To read from standard input:

Scanner scanner = newScanner(System.in);

BufferedReader br=newBufferedReader(newInputStreamReader(java.lang.System.in));

 

To read from classpath:

InputStream in =

this.getClass().getResourceAsStream("/com/spindleware/SampleMessage.txt");
Reader reader = new InputStreamReader(in);
char cbuf[] = newchar[10000];

reader.read(cbuf);