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 a txt file and storing them in a Java Array

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

    Default Reading a txt file and storing them in a Java Array

    I am in the middle of a coding experiment, and generally everything has went smoothly until this very last part. I really have no idea where to even begin with this sub question, and it's really stressing me out like you cant believe. I've tried way after way only getting errors. And it's a real downer because everything before it had pretty much after it went well. I've written nearly 500 lines of code everything working properly, and just as you begin nearing the end, happy that everything went more or less smoothly throughout (although there were some errors which had to be worked around like with any series of codes, but we are all human after all) you get stopped dead set in your tracks of progress. This would be ok if time was a luxury you have, but unfortunately, at this stage it's not really something in abundance. For this little sub problem, It's just I have no idea where to begin, and even after reading some tutorials, I am still having some major trouble with getting it to work right.

    Basically, I have to read this txt file, ( link to the text file)
    HTML Code:
    http://www.mediafire.com/view/?a6d7c0c5cdu1gup
    and put the data into 5 arrays (without a scanner)

    The Name has to go into the Name array, the N/Y has to go into the Before array, the next column of numbers have to go into into the timespent array, the next column has to go into the assistants array and the last row has to go into the risk array.

    So we have 5 Arrays

    String Name [] = new String [20)
     
    Char Before [] = new Char [20]
     
    Int timeSpent [] = new Int [20]
     
    Int Assistants [] = new int [20]
     
    Double Risk [] = new Double [20]

    So these are the 5 arrays that i've made, but what I am having trouble with is actually reading the text file and writing it so that the appropriate column goes into the appropriate array.

    So any help with getting my code together and those values into there proper respective arrays so that I can continue would be very, very greatly appreciated. Please help, I am about to pull my hair out lol. After writing so much code, looking at the screen for so long and getting so much accomplished relatively hassle free, and just as your nearing the then hitting a road block so huge you don't even know where to begin and ontop of that time being a luxury you don't have and ontop of that, the remaining little sub problems (which after reading I know for sure how to do, as i've done such problems before) all depend on this problems output so I cant even move on if I wanted to, it's all just really really getting to me. I feel like I am about to explode. Ahh, but what can you do but be patient and ask for help when you need it. Anyhow, any help on this would be much appreciated. Thanks alot.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,409
    Thanks
    49
    Thanked 2,214 Times in 2,187 Posts

    Default Re: Reading a txt file and storing them in a Java Array

    Can you describe how the data in the file is supposed to be separated into the parts that go into the arrays?
    Does each line have 5 pieces of data, one for each array
    or is each piece of data on a separate line?

    Can you post the code that is trying to read lines from the file and shows how you are getting the data for each array? Be sure to use code tags with the code.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: December 2nd, 2011, 10:53 AM
  2. Storing data from a file in array and setting it to textbox
    By macko in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 13th, 2011, 09:17 PM
  3. HELP with reading a clients ip address and storing in a text file.
    By dannyyy in forum Java Theory & Questions
    Replies: 1
    Last Post: April 4th, 2011, 07:20 AM
  4. [SOLVED] Reading from a text file and storing in arrayList
    By nynamyna in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 26th, 2010, 09:55 PM
  5. Reading .txt and storing into an array
    By vluong in forum Collections and Generics
    Replies: 1
    Last Post: January 4th, 2010, 01:07 PM