Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert a String to a Byte Stream  RSS feed

 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!