• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help to read binary files

 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Actually I have a binary file in which Binary fields are stored in LSB_LO format. So, can anyone please tell me how can I read this file and how can I convert this file in to normal string presentation?

I have tried to read file with FileInputStream. Then I getBytes() from that file and after getting bytearray I converted one by one byte in Hex format.

But I don't know how to parse?

Thanks
James
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is this LSB_LO format? Do you have the specification for that?

And what's this "getBytes()" method? I hope you're not talking about String's getBytes() method? Because you cannot use Strings for binary files. To convert a binary file to a byte array use ByteArrayOutputStream; copy all data from the FileInputStream to the ByteArrayOutputStream, then call the latter's toByteArray() method to get the byte array.
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:What is this LSB_LO format? Do you have the specification for that?

And what's this "getBytes()" method? I hope you're not talking about String's getBytes() method? Because you cannot use Strings for binary files. To convert a binary file to a byte array use ByteArrayOutputStream; copy all data from the FileInputStream to the ByteArrayOutputStream, then call the latter's toByteArray() method to get the byte array.


Hi Rob

Thanks for reply!!!

Actually LSB_LO format; i.e. the least significant byte of the binary number. So, whole file is written in this format. And yes I haven't used getBytes() of String I am just telling that I have a method which reads whole file and returns byte array of that.

And then I took one by one byte from that and converted in to HEX format. But I don't know what will be the next step I need to follow.

Thanks
James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic