Results 1 to 2 of 2
  1. #1
    maskanio is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default Scanning a txt file with Java?

    I know how to read a txt file in Java but what I dont know how to do is scan a txt file in java based on a starting value a user gives me.

    For example: Say I have a txt file with a list from 1-20. ANd after each of those numbers is a answer to a math problem. Sure I can read it normally but how do I go about getting everything after that one number the user gave me? I just made this up below but you should get the idea.

    A user inputs the number 1
    The program scans the txt file for the first 1 that appears
    The program then outputs the rest of the line after 1.

    1. 5460
    2. 8475
    3. 4850
    4. 9121

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Scanning a txt file with Java?

    Performing IO is expensive (resource wise). So you want to read the text file once and store all the data in a Collection. Afterwards you can search/sort your data which is much simpler.

Similar Threads

  1. Java Twain Scanning
    By mwalstra in forum Advanced Java
    Replies: 4
    Last Post: 10-28-2014, 11:57 AM
  2. Scanning a Plain text file
    By aw249 in forum New To Java
    Replies: 3
    Last Post: 02-03-2012, 05:16 PM
  3. Scanning text file and inserting contents into array
    By jmwalloh in forum New To Java
    Replies: 8
    Last Post: 03-24-2010, 12:33 PM
  4. Scanning in java
    By Waqas in forum Advanced Java
    Replies: 1
    Last Post: 07-10-2009, 08:38 AM
  5. scanning a file and using more than one delimiter
    By thomase in forum New To Java
    Replies: 20
    Last Post: 04-07-2009, 03:04 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