File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes converting from binary to ascii Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting from binary to ascii" Watch "converting from binary to ascii" New topic

converting from binary to ascii

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
Does anyone know of an algorithm to convert a .pcx file, which is a binary
file, to ascii?

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Anything binary can be converted (reversibly) to ASCII by the Base64 encoding. One of the libraries that implements it is Jakarta Commons Codec. Understand, though, that no image-specific operations can be performed on that ASCII representation until it is decoded back to binary.
[ January 04, 2007: Message edited by: Ulf Dittmer ]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
can try apaches commons codec package.

Rahul Bhattacharjee
LinkedIn - Blog
Henry Wong

Joined: Sep 28, 2004
Posts: 20531

Base64 encoding (and decoding) is actually built into the JVM core classes -- via the sun.misc.BASE64Encoder and sun.misc.BASE64Decoder classes.

Interestingly, these classes have come into "common" usage to the point that they are also built into the IBM JVM as well. (with the same package and class names)


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Lucas Lee
Ranch Hand

Joined: Oct 02, 2006
Posts: 53
Use Base64 or other similar encoding algorithm.
But you need pay attention to that encoding will enlarge the file size to 1.33 times.
I agree. Here's the link:
subject: converting from binary to ascii
It's not a secret anymore!