Results 1 to 2 of 2
  1. #1
    cavsfan223 is offline Member
    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Default reading in file and storing in array

    I have to read in a file like this:

    meaning
    something that one wishes to convey, especially by language

    term
    a word whose definition is in a glossary

    word
    a string of characters in a language, which has at least one character

    definition
    a sequence of words that gives meaning to a term

    glossary
    a list of difficult or specialized terms, with their definitions,
    usually near the end of a book

    language
    a set of strings of characters, each of which has meaning

    book
    a printed or written literary work

    I need to store the terms and definitions in separate arrays. However in the same order respectively so they still align. Is there a good way to do this?

  2. #2
    Junky's Avatar
    Junky is online now Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default Re: reading in file and storing in array

    Well the best way would be to create objects and store them in a Collection but I guess that is beyond your learning at this stage. What you need to do is read a line of text, store in term array, read a line of text, store in definitions array, repeat until reach end of file. If there are actually blank lines then you will need to handle them as well.

Similar Threads

  1. Replies: 1
    Last Post: 11-11-2012, 01:55 AM
  2. read a data file and storing it in an array
    By jwl in forum New To Java
    Replies: 3
    Last Post: 10-27-2012, 12:44 AM
  3. Reading input and storing into array
    By joeyalf in forum New To Java
    Replies: 1
    Last Post: 12-04-2011, 08:08 PM
  4. Replies: 3
    Last Post: 11-11-2010, 10:22 AM
  5. Reading a txt file and then storing it in a 2d array
    By blkshp1990 in forum New To Java
    Replies: 2
    Last Post: 11-05-2009, 12:31 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
  •