Posted By:
derwood_king
Posted On:
Wednesday, October 5, 2005 12:32 PM
Hi, I am totally lost on how to deserialize (and reconstruct) an image taken from a java space. I recall seeing a reference stating that an image had to be serialized before it could be written to a java space. To serialize the image (PNG) this is my code: InputStream is = new FileInputStream(image); long length = image.length(); byte[] bytes = new byte[(int)length]; int offset = 0; int numRead = 0; while(offset < bytes.length && (numRead=is.read(bytes,offset,bytes.length-offset)) >= 0){ offset += numRead; } is.close(); //now wrap byte array with Byte wrapper Byte[] array
More>>
Hi,
I am totally lost on how to deserialize (and reconstruct)
an image taken from a java space. I recall seeing a
reference stating that an image had to be serialized
before it could be written to a java space.
To serialize the image (PNG) this is my code:
InputStream is = new FileInputStream(image);
long length = image.length();
byte[] bytes = new byte[(int)length];
int offset = 0;
int numRead = 0;
while(offset
< bytes.length
&& (numRead=is.read(bytes,offset,bytes.length-offset)) >= 0){
offset += numRead;
}
is.close();
//now wrap byte array with Byte wrapper
Byte[] array = new Byte[bytes.length];
for(int i=0;i
array[i] = new Byte(bytes[i]);
System.out.println(array[i]);
}
I then create an entry, containg this Byte array and write
to java space. I can successfully take it from the java
space.
At this point, how do I deserialize (and reconstruct) this
Byte array into an object that I can display in HTML?
Or is my approach plain wrong?
TIA,
derwood
<<Less