Results 1 to 9 of 9
  1. #1
    ivvgangadhar is offline Member
    Join Date
    Nov 2008
    Posts
    13
    Rep Power
    0

    Default Reading specific lines

    Hi,

    My requirement is to read a text file using java code from a specified line number.

    For example:-Text file consists of 10 lakhs of lines,but i want to read the file from some 7500th line to the end.is there any api to skip all these 7500 lines,so that i can go directly to the required line to read the file.

    If any solution mail me as soon as possible,Urgent

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Spin the wheels...

    Not being an expert, but I haven't been able to find an elegant (aka method) to do this. What you could do is just read the first 7500 lines of the file and do nothing with them (with a for loop). Once you are at the correct line to work with, just start processing the way you want. I admit that this may not be the most efficent way to do this, but it should work.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    I think CJSLman's is the only way, because, to know where is the 7500th line, you MUST first read 7500 '\n', so you'll end up reading 7500 lines of text to find the '\n' char.... IMHO :)

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default lakhs?

    @Raffaele: thanks for confirming I'm not as crazy as I thought :)

    @ivvgangadhar:
    ... 10 lakhs of lines
    What are "lakhs"?

    Thanks,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    I think he's talking about in millions. Hundred thousands referred as a lakh, isn't it? In Asian countries it's very common word.

  6. #6
    ivvgangadhar is offline Member
    Join Date
    Nov 2008
    Posts
    13
    Rep Power
    0

    Default

    i am very thankful for your response.

    I already done in the way what CJSLMAN told.But it will be a performance issue.

    Ya Eranga you are right,i am talking about the millions(lakhs)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  8. #8
    ivvgangadhar is offline Member
    Join Date
    Nov 2008
    Posts
    13
    Rep Power
    0

    Default

    Performance issues in the sense,Time measurement

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Either ResultSet or a specific object?
    By saul_2110 in forum JDBC
    Replies: 3
    Last Post: 12-06-2008, 07:41 AM
  2. Replies: 2
    Last Post: 11-08-2008, 10:40 AM
  3. Open specific folder form JSP
    By roseline43 in forum New To Java
    Replies: 2
    Last Post: 09-02-2008, 07:53 PM
  4. Select specific cell
    By Echilon in forum New To Java
    Replies: 1
    Last Post: 01-01-2008, 07:47 AM
  5. Rejecting connections from a specific IP
    By javaplus in forum Networking
    Replies: 2
    Last Post: 12-21-2007, 02:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •