I'm having problems converting my image back to jpeg format. The code i used to get from jpeg to hex is as follows:

for (int i = 0; i < ba.length; i++) {
String hex = Integer.toHexString(0x0100 + (ba[i] & 0x00FF)).
ret.append((hex.length() < 2 ? "0" : "") + hex);


ba is a byte[] which contains the image in jpeg format
ret is a string buffer, which stores the image in hex format.

i can't work out how to convert back to jpeg format

thank you in advance