Results 1 to 2 of 2
  1. #1
    baltimore is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    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.

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    I would use a linked list (java.util.LinkedList) to put the lines in.

    Java 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.

Similar Threads

  1. Reading data from Micrsoft excel and writing to notepad
    By abhishek.jain in forum New To Java
    Replies: 4
    Last Post: 01-29-2009, 08:12 AM
  2. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 04:34 AM
  3. Reading/Writing a File using byte array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 10:41 AM
  4. Reading/Writing files through Applet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-15-2007, 08:20 PM
  5. writing to a file
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-11-2007, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •