Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 05:27 PM
Member
 
Join Date: Jul 2007
Posts: 40
Rep Power: 0
baltimore is on a distinguished road
Default Help with File reading and writing
Hi, I am having problem and just need some coding lines that reads a file into an array so it can be edited in the array and than rewrites it to the file later on.

Also another question, is there a way to add more to an array with out creating a new one and so forth?

Thanks.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-31-2007, 07:47 PM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
I would use a linked list (java.util.LinkedList) to put the lines in.

Code:
LinkedList lineList = new LinkedList();
BufferedReader br = new BufferedReader(new FileReader("FileName"));
String line;
while ((line = br.readLine()) != null)
{
lineList.add(line);
}
br.close();
On output I would use a PrintWriter and an Iterator over the LinkedList.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading data from Micrsoft excel and writing to notepad abhishek.jain New To Java 4 01-29-2009 09:12 AM
writing and reading unicode characters from a file ranoosh Advanced Java 4 09-28-2008 05:34 AM
Reading/Writing a File using byte array Java Tip Java Tips 0 01-16-2008 11:41 AM
Reading/Writing files through Applet Java Tip Java Tips 0 12-15-2007 09:20 PM
writing to a file bugger New To Java 1 11-11-2007 03:49 AM


All times are GMT +2. The time now is 06:14 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org