0

I am a beginner and I have a file having variable sized records; there are two fields per row i.e. one is 7-15 digits key and then followed by space there is a string which is also variable sized for each record.

I am trying to read bytes only of page size into my buffer and then process them.

The problem is that if i use Java.RanomAccessFile and use seek method to reach a particular line , then i use ReadFully method to read those 1024 bytes into my buffer. I have written the functions to convert byte into int and byte into string -but the problem is that I dont know how many bytes form that 7-15 digit and how many bytes form my string.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Basmah
  • 829
  • 3
  • 13
  • 25

1 Answers1

0

When you say a row, do you mean each row has a line separator in between? If that is the case, you can use something like BufferedReader's readline() method. That gives you a string which is 1 line without the line separator.

Pavan
  • 1,245
  • 7
  • 10
  • No the problem is that I have 15 gb data that I want to read. SO if I read Line by line it will take time, that's why i want to read page by page from my files ; moreover i am not sure how records will fit in page size. I have to write some code that tries to read my records in the pagesize defined until the page doesnot become full. If further adding of record exceeds the page size then dont bring that record from file. Thank you! – Basmah Nov 16 '11 at 16:56
  • If that is the case, then you have to bite the bullet and read into a buffer and then peek into seeing if you have read an entire row. If not, read more of the same buffer size, until you read an entire row. – Pavan Nov 18 '11 at 17:15