• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Converting File to Bytes and reading it in loop

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic