• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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 ]
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic