Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Help to read binary files

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22055
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic