Results 1 to 2 of 2
Thread: File Reading
- 05-10-2010, 03:39 AM #1
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
File Reading
How do I finish this code using a While loop to read each line of a BufferedFileReader into the fileData ArrayList. I cant alter the following code I can only add to it.
Java Code:ArrayList<String> fileData = new ArrayList<String>(); //Assume file.txt contains the lines of data i need and is in current directory BufferedFileReader reader = new BufferedFileReader(new FileReader("file.txt")); String currentLine = ""; eof = false;Last edited by nuggetman4; 05-10-2010 at 07:06 PM. Reason: To clarify
- 05-10-2010, 05:49 AM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
I recommend to use code like a
Java Code:BufferedFileReader in = new BufferedFileReader(); for (int i=0; i < nargs; i++) { try { in.open(args[i]); while ((line = in.readLine()) != null) { //<----- nlines++; } in.close(); } catch (Exception e) { System.out.println(" BFRTest: exception:" + e ); }If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
Similar Threads
-
Reading a file
By fenwick in forum New To JavaReplies: 19Last Post: 02-22-2010, 04:01 AM -
Reading and Writing the contents of a file to another file
By priyankatxs in forum New To JavaReplies: 9Last Post: 10-20-2009, 10:52 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-09-2009, 11:31 PM -
reading csv file help
By fritz1474 in forum New To JavaReplies: 5Last Post: 09-04-2008, 08:41 PM -
Reading from a file
By leebee in forum New To JavaReplies: 1Last Post: 07-23-2007, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks