How to Convert Binary Data in Binary File
hi,my telecom client puts a binary file which is asn.1 encoded with BER.how to handle binary data in java.how to convert binary to hexa to ascii formathow to convert binary to octet to ascii formatplease help me in this.regards,s.mohamed
# 1
java.io.InputStream.read(byte[] b) will get you an array of bytes, for you to use as you please.Or use a ReadableByteChannel, store the data in a ByteBuffer,and decode it using a CharsetDecoder of your choice.
Bavona at 2007-7-12 21:59:50 >

# 2
You don't need to convert the data.
Only you can do is print it in that formats, like it:
public static String byteArrayToHex(byte[] b) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < b.length; i++)
sb.append(Integer.toHexString(b[i]&255) + " ");
return sb.toString();
}
take a look at this
http://java.sun.com/docs/books/tutorial/essential/io/