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.


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

Results 1 to 2 of 2

Thread: Reading lines in files with tabs

  1. #1
    Join Date
    Dec 2011
    My Mood
    Thanked 0 Times in 0 Posts

    Default Reading lines in files with tabs

    I've used the scanner class before, and I know how to use the delimiter and all that, but I have come to a problem. For my program to work(it parses data into a text file which is being separated by tabs to specify which object it's using, if that makes sense), I need to be able to grab every integer inside the text file that's being separated.

    I'll show an example:

    This is what's inside the text file
    robert = 30\t 55\t 5005\t 500

    Now I want to print out the numbers separately like this

    Any way I can do this?

    I've seen people do it using buffered reader, but in my opinion it's a hassle and takes too much code.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,444 Times in 2,395 Posts

    Default Re: Reading lines in files with tabs

    How are you using the Scanner class and its methods? Post code that compiles and executes to show your problem. For testing use a String in the code for input instead of having a file.
    String input = "robert = 30\t 55\t 5005\t 500";

Similar Threads

  1. Reading lines of a text file into a string array
    By fortune2k in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 11th, 2010, 11:56 AM
  2. reading a certain amount of lines from a file?
    By welikedogs in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 3rd, 2010, 01:28 PM
  3. Reading a lines from text file
    By kiran in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: September 26th, 2010, 10:54 PM
  4. [SOLVED] reading only certain lines from a .txt file
    By straw in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: March 7th, 2010, 07:49 PM
  5. Reading from a file, multiple lines
    By MysticDeath in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: October 15th, 2009, 02:40 AM