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: read a text file containing multiple lines

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    18
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default read a text file containing multiple lines

    So in this file I have like 20 lines. each line has 2 word seperated by ;
    This is what I did so far
    FileInputStreamReader f = new FileInputStreamReader(C://Desktop/test.txt);
    InputStreamReader reader = new InputStreamReader(f);
    BufferedReader Buff = new BufferedReader (reader);
    String x = Buff.readLine();

    I don't how to go to the second line


  2. #2
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: read a text file containing multiple lines

    Quote Originally Posted by e93 View Post
    I don't how to go to the second line
    Do a loop. readLine() returns null on end-of-file. So loop "if readLine() is not null".
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

Similar Threads

  1. Java code Split text file into multiple text file
    By jayraj in forum What's Wrong With My Code?
    Replies: 26
    Last Post: April 19th, 2013, 06:14 AM
  2. How to skip and read lines in txt file
    By saran123 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: December 26th, 2012, 07:07 AM
  3. Beginner I/O Help: Writing To a Text File At the End of Existing Lines of Text
    By BloomingNutria in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 28th, 2012, 02:03 PM
  4. 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
  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