Results 1 to 2 of 2
  1. #1
    janey4115 is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default read from text file into array of objects

    Hi - can anyone share a simple example of how to read from a text file into an array of objects?

    text file example:
    Part ID: MOV001, Part No: PG, Description: Wheel
    Part ID: MOV234, Party No: G, Description: Tyre

    I wish to write this details into an array of part objects

    Parts [] part = new Parts [10];

    start of code:

    BufferedReader bufr = new BufferedReader(new FileReader ("part.txt"));

    Unsure how to go from here?

  2. #2
    dheaven is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: read from text file into array of objects

    If you already have your Parts class, you just need to read your data from the text file.
    Here are some tutorials on how to do that:
    Dystopian Code: Text File I/O in Java
    Dystopian Code: Text File I/O with Strings that Contain Spaces in Java

Similar Threads

  1. Replies: 2
    Last Post: 04-01-2011, 03:04 PM
  2. Replies: 2
    Last Post: 03-25-2011, 02:36 PM
  3. Replies: 7
    Last Post: 11-01-2010, 02:04 PM
  4. Replies: 1
    Last Post: 01-22-2009, 04:25 PM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 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
  •