• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting File to Bytes and reading it in loop  RSS feed

 
Gangrade Sumit
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have somehow got stuck in this -

-------------------------------------------------------------------
Each time I need to read only max 0f 100 bytes from a file and then need to convert bytes to String and do some processing.

Then I want to read next 100 bytes. this needs to go on till EOF.

-------------------------------------------------------------------

Thanks in Advance
Sumit
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are using 1.4.x and are dealing with files of size that won't blow you memory, you could read the file into a ByteBuffer and use a byte array (of size 10) to fetch the intermediate chunks.

eg

I use a variation of this style of code for library IO functions. Note that the example I'm using is adapted from a tip in Sun Performance Tips - you can find more variations on the same there.

hth
[ May 15, 2004: Message edited by: clio katz ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!