Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with FileReader/Writer in java please!
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
David(0.0)




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Unnamed




PostPosted: 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!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: