Friday, January 9, 2009

The classic IO code

Get string from keyboard:

String input;
BufferedReader buf = new BufferedReader(new InputStreamReader(
System.in));
input = buf.readLine();

Write strings to the created file:

File f = new File(outfile);
f.createNewFile();

BufferedWriter output = new BufferedWriter(new FileWriter(f));
String out = "this is for test.";
output.write(out);
output.close();

No comments: