Results 1 to 5 of 5
  1. #1
    Exhonour is offline Member
    Join Date
    Jan 2009
    Posts
    21
    Rep Power
    0

    Default Data files - how to read random line?

    Like i got a list of stuff and I want a random one inputted, how do i do this?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I can't imagine that your data file is all that large. The best way is probably to read it all in to a data structure such as an arraylist, and then extract your line. Either that or read the file line by line until you get to the line of interest.

  3. #3
    Exhonour is offline Member
    Join Date
    Jan 2009
    Posts
    21
    Rep Power
    0

    Default

    Not that its large, its cuz I need to pick up a random puzzle/category for hangman assignment.

    But putting it into array list is a good idea cant believe I didnt think of that... Too late now, class ending in few mins and exams tommorow for the rest of the week.

    O well

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Well, good luck on your exams -- knock 'em dead!

  5. #5
    Exhonour is offline Member
    Join Date
    Jan 2009
    Posts
    21
    Rep Power
    0

Similar Threads

  1. [SOLVED] read last line
    By Azndaddy in forum New To Java
    Replies: 22
    Last Post: 04-22-2012, 09:22 PM
  2. [SOLVED] Read/write files using applets
    By coolFrenzi in forum Advanced Java
    Replies: 3
    Last Post: 11-17-2008, 10:45 PM
  3. read the file from different line number
    By vaskarbasak in forum Advanced Java
    Replies: 3
    Last Post: 06-02-2008, 01:31 PM
  4. Random Access Files concept
    By AralX in forum New To Java
    Replies: 2
    Last Post: 12-25-2007, 07:04 PM
  5. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 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
  •