Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Reading file into array. PLEASE HELP! :)

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading file into array. PLEASE HELP! :)

    Hi everyone. I'm very new to programming. I have a file titled AwardYears.txt and need help reading the file into an array. I have the code for everything else I need to do with the array, I just don't know how to input it from the file.
    The text file looks like this:
    Award Winners from 1990 to 2010
    John Smith 1999 2000 2009 2010
    John Doe 2000 2001 2002
    Jane Doe 2001 2004 2005
    Bob Angelo 1992 1995 2002

    I need to input the names into name variables and the dates into date variables. Any advice on how to do this?


  2. #2
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: Reading file into array. PLEASE HELP! :)

    To get started reading from a file I suggest one of these:
    Scanner (Java 2 Platform SE 5.0)
    BufferedReader (Java 2 Platform SE 5.0)
    Although, I am partial to the Scanner class, both work nicely. Now, without knowing whether you are going to just use a one dimensional array of type String to hold the data or something more object oriented, I can't really help much more than that. When you say "name variables" and "date variables" it is impossible to deduce if you are suggesting there is a name class and a date class or if they are just Strings. Showing the code that you have so far could help out a bit.

Similar Threads

  1. Trouble with writing/reading array to/from file
    By MaximusPrime in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 4th, 2012, 08:41 PM
  2. Replies: 3
    Last Post: December 2nd, 2011, 11:53 AM
  3. [SOLVED] Reading file and adding it to an array through a method
    By PeskyToaster in forum Collections and Generics
    Replies: 20
    Last Post: November 10th, 2011, 01:16 AM
  4. Reading from a sequential file to an array
    By Xrrak in forum File I/O & Other I/O Streams
    Replies: 15
    Last Post: August 20th, 2011, 01:33 PM
  5. Reading a file, then putting it in an array
    By Gondee in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 16th, 2010, 11:11 AM