Read a file with 2048 bytes

Posted by Suresh S on Stack Overflow See other posts from Stack Overflow or by Suresh S
Published on 2010-12-27T10:08:06Z Indexed on 2010/12/27 14:53 UTC
Read the original article Hit count: 216

Filed under:
|

Guys i have a file which has only one line. The file has no encoding it is a simple text file with single line.

For every 2048 byte in a line , there is new record of 151 byte (totally 13*151 byte = 1945 records + 85 byte empty space). similarly for the next 2048 bytes.

What is the best file i/o to use? i am thinking of reading 2048 bytes from file and storing it in an array .

while (offset < fileLength &&(numRead=in.read(recordChunks, offset,alength)) >= 0) 
{ 
}

how can i get from the read statement only 2048 bytes at a time . i am getting IndexOutofBoundException.

© Stack Overflow or respective owner

Related posts about java

Related posts about file-io