Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convert text/ascii file to binary file  RSS feed

 
sreedhara satuluri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,

i have a file in the format of text as well as ascii , i would like to convert this file as binary and store it to another file (i m creating this file) file using java program can any one suggest this one how to do this
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you give an example of what you mean by binary?
For example: text = 'A', binary = "01000001"
these are Strings or characters.
but really the binary for 'A' is x41 or as an int - decimal 65 etc

There are methods to create String representations. See the Integer class.

Everything on a computer is in binary. The meaning a particular grouping of bytes depends on the context. The same bytes could represent a character or a machine instruction or part of an image. Depends how you use them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!