Hi!
I am gettting from somewhere a List object. and there are three elements:
image(byte[])
imagename(String)
imagedescription(String)
And now i am in a big trouble because i can't convert object to byte[]. I am sending image 5kb long... but my byte[] is just 353 in length:( allways. What am i doing wrong?
public static void saveImage(List request){
tracemsg(request.toString());
//byte[] bytes=(byte[])request.get(0);
try{
byte[] bytes=getBytes(request.get(0));
Integer b=bytes.length;
String s=b.toString();
tracemsg(b); // 353!!!
}catch (Exception e) {
tracemsg(e.toString());
}
}
-----------------------
public static byte[] getBytes(Object obj) throws java.io.IOException{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
oos.close();
bos.close();
byte [] data = bos.toByteArray();
return data;
}