• Post Reply Bookmark Topic Watch Topic
  • New Topic

convert Binary file to a text file  RSS feed

 
ravicnew kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to read a binary file & convert it into a text file
The binary file can contain both numbers & alphabets..
can someone provide a sample code that will help me in doing this..

thanks
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you have the exact structure of your file, you might want to look at DataInputStream!
Hope this helps!
Abhik.
 
ravicnew kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i don't know the structure of the file...one thing i know is that it will be always a file generated from Test & numbers.. what i mean is that it won't be any image file or something.
the text & number data in the binary format can be changing..
even if the text was not changing who will i know when to use a readInt or when to use a readByte or something...
 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not going to be able to interpret a binary file without knowing its *EXACT* data structure before hand. There is no way to infer the data type of an arbitrary group of bytes.
Ever wonder what the fuss about xml was about? XML makes this type of thing trivial, you just look for the correct element tags and extract the needed data.
Michael Crutcher
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!