aspose file tools*
The moose likes I/O and Streams and the fly likes Help to read binary files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Help to read binary files" Watch "Help to read binary files" New topic
Author

Help to read binary files

James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
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

Joined: Oct 27, 2005
Posts: 19697
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help to read binary files