Computer Science Canada

Help with FileReader/Writer in java please!

Author:  David(0.0) [ Thu Oct 27, 2011 9:27 am ]
Post subject:  Help with FileReader/Writer in java please!

I recently did the Dwite contest and failed miserably because i coded my fileReader and Writer wrong lol. Confused
It would be a huge help if someone can send me a link that explains how to use it.

Author:  Unnamed [ Thu Oct 27, 2011 8:12 pm ]
Post subject:  Re: Help with FileReader/Writer in java please!

I'm not sure of how much knowledge you have of java, but you can easily create BufferedReader (or Scanner if you are using Java 1.5+) and PrintWriter objects for input and output respectively.

Java 1.4.2 (should be supported by your school) http://download.oracle.com/javase/1.4.2/docs/api/

Java 1.6 http://download.oracle.com/javase/6/docs/api/

In the APIs, look for BufferedReader and PrintWriter and look for the methods that you can use.

Java:

//Example Creation of the objects for File I/O

BufferedReader bf = new BufferedReader (new FileReader("DATA.txt"));
PrintWriter pw = new PrintWriter (new FileWriter ("OUT.txt"));

bf.readLine() //read a lint of input
pw.println() //write a line of output.

pw.close() //don't forget this!


: