File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Converting binary file to ACII file 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 binary file to ACII file" Watch "Converting binary file to ACII file" New topic
Author

Converting binary file to ACII file

sankar dunga
Greenhorn

Joined: Mar 07, 2011
Posts: 16
Hello sir,

I want convert the binary file into acii file by using java code.
I want to convert total binary file into another new ascii file.
Can anybody help me to do it, please[/b]


Regards
sankar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
Binary data is not text data, much less necessarily ASCII data - so there is no conversion that will work in general. What may work is to base-64 encode the data; the Apache Commons Codec library can help with that.

Maybe you can tell us why you want to do this.


Ping & DNS - my free Android networking tools app
sankar dunga
Greenhorn

Joined: Mar 07, 2011
Posts: 16
yah sure sir,

I want convert binary data from the source file to ascii file. Because i want to load data into database.
Ascii is the user friendly data type, so i want conver the data to ascii format before loading into the database.

Please give me the best suggestion to do this.
And what is the use of base64 encoding. Is it gives the result as ascii format.

Thank you.


Regards
sankar.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yes, Base64 encoding will allow you to represent binary data in ASCII form and then load it into a database as character data.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

eg http://iharder.sourceforge.net/current/java/base64/
sankar dunga
Greenhorn

Joined: Mar 07, 2011
Posts: 16
Thank you so much.

Actually i tried with base64, The starting variable as follows

/*
private static final String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + /";
private static final int splitLinesAt = 76;

*/

But when i run this code it is giving different output than what i am expecting.

Any way i will try with your suggestion

Thank you

Regards
sankar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
sankar dunga wrote:But when i run this code it is giving different output than what i am expecting.

We might be able to help with this if a) we knew what output you got, and b) what output you were expecting. Seeing the actual code you used to base-64 encode the data -and to output it- would also help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

I'd go for a BLOB database field and just store the data in binary form. PreparedStatement and ResultSet can handle binary values just fine.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting binary file to ACII file