Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert a String to a Byte Stream

 
Bharath Iyengar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have converted a file to a string representation. I need to parse it based on byte positions. Such as the first 200 Bytes and then from Byte 450 to 500 etc

How do i do this?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me like it would be more appropriate to use a FileInputStream to read a desired number of bytes from the file, process those bytes accordingly and continu that process of reading/processing until the end of the file is reached or all relevant bytes have been processed. Anyway, if that is somehow not an option you could use String#getBytes() to fill a ByteArrayInputStream, I guess.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic