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: How to skip and read lines in txt file

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to skip and read lines in txt file

    Hi to all,

    I want to skip and read the lines based on the JSlider movement. While change the JSlider position, it'll return a integer value. Based on the value, I want to read the particular line and continue reading.

    How to skip & read the lines.

    Thanks in advance.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to skip and read lines in txt file

    With most files, to read the nth line, all the lines before the nth line need to be read. An exception is when all the lines are the same length. Then you can use the RandomAccessFile class to start reading at the start of the nth line by skipping over n*line-length bytes.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Can't work out how to read object from .txt file
    By goformickey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 25th, 2012, 01:27 AM
  2. Program to read .TXT file one line at a time
    By JustForLawls in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 27th, 2012, 02:02 PM
  3. Read .txt file and create objects using data
    By sevans20 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 14th, 2012, 01:52 PM
  4. Codes skip some lines??
    By bczm8703 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 21st, 2011, 08:39 AM
  5. [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