I retrieved an Oracle RAW(32) field by byte b= statement.getBytes(n). Somehow, I need to have the String represtation of this field, and later also need to convert back to the byte. When I use new String(b), it just gives me some unreadable symbols. While at the same time, I know this field have a value like: A95C92500B885926E0340003BA16A687. Thanks in advance!
Joined: Nov 28, 2000
Most likely, the byte array you are getting from the database is not the byte array you assume you are getting. With the String(byte) constructor, the String class assumes that each byte in the byte array is a character. Thus, if you have the byte array [65, 66] the constructor String(byte) will create the String "AB". However, the byte array could be in a different encoding, in which case you should use the constructor String(byte, String) where the second parameter is the encoding and would correctly convert the byte array. To help narrow down the problem: After you get the byte array, print out the value of each byte. After creating the String, use the String.getBytes() method and print out the value of each byte. Post the results here. KMukhar http://home.earthlink.net/~kmukhar/