Results 1 to 4 of 4
  1. #1
    tomtaila is offline Member
    Join Date
    Jul 2011
    Posts
    21
    Rep Power
    0

    Default Help needed to read/get information from a text file plz

    I have a class actor which holds two instance variables: 'String name' and 'ArrayList<String> movie_titles'
    To define these variables I will need to import the information from a file which has the following structure:

    Attachment 2425


    etc...

    Any ideas on how I could do this anyone? Or any links as to where I can learn how to do this would be really helpful, thank you all so much

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default Re: Help needed to read/get information from a text file plz

    First you will need to read the lines from the file into your program as Strings.
    The Scanner class will help you do that.
    Once you can read the lines from the file, you will need to "parse" the lines to extract the information you want to save. To do this "parsing" you will need to understand where the data is that you want to save. You will need some "rules" that define where in the lines the data is. For example some lines start in the first character of the line and some lines have leading spaces.

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

    Default Re: Help needed to read/get information from a text file plz


  4. #4
    tomtaila is offline Member
    Join Date
    Jul 2011
    Posts
    21
    Rep Power
    0

    Default Re: Help needed to read/get information from a text file plz

    Thankyou both so much, I'll give it a shot at some point during tonight and let you know how it goes, fingers crossed. Thanks again

Similar Threads

  1. Replies: 1
    Last Post: 01-10-2012, 12:49 PM
  2. Replies: 0
    Last Post: 11-15-2011, 09:13 PM
  3. need to read information from file into array
    By sadeem in forum New To Java
    Replies: 8
    Last Post: 05-15-2011, 10:00 PM
  4. Help needed: read array from file and then use it
    By ChicagoAve in forum New To Java
    Replies: 11
    Last Post: 02-18-2011, 01:02 PM
  5. Replies: 2
    Last Post: 11-29-2009, 10:26 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
  •