read a file from different line number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vaskarbasak
    New Member
    • Feb 2008
    • 27

    read a file from different line number

    Hi All,

    I have a text file.The file size is very big.I have to read the file from different line number.
    e.g

    File test.txt contains 10000000 lines and more.The 1st thread read the file from line 1 to 1000.2 nd thread read the file from line 1100 to 2000.3 rd thread read the file from line 2100 to 3000.. so on.

    Please help me.

    Thanks!
    vaskar
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by vaskarbasak
    Hi All,

    I have a text file.The file size is very big.I have to read the file from different line number.
    e.g

    File test.txt contains 10000000 lines and more.The 1st thread read the file from line 1 to 1000.2 nd thread read the file from line 1100 to 2000.3 rd thread read the file from line 2100 to 3000.. so on.

    Please help me.

    Thanks!
    vaskar
    Better have one thread read the entire file and dispatch chunks of it to different
    threads. A hard disk can 'read ahead' and your scenario spoils that. Also have
    a look at the API documentation for the ByteBuffer class.

    kind regards,

    Jos

    Comment

    Working...