Hi experts,
I have a small issue in accomplishing a task. I need to convert a byte array to an image. I get this byte array as an array object from an action script class.
I use the below given code snippet to do the conversion. The error I get while doing this conversion in server console is shown in
https://docs.google.com/leaf?id=0BwhgDtGvE2HgZTFmZjMwOTEtNjkxZi00NmY2LWEwMzgtYTVjZmZkYzc4MDVk&authkey=CNTb_sgK&hl=en
Code snippet is as shown.
public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
{
try {
ActionscriptObject arr = ao.getObj("arr");
String dirName="C:\\";
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos;
oos = new ObjectOutputStream(bos);
oos.writeObject(arr.getNumber(0));
oos.flush();
oos.close();
bos.close();
byte [] data = bos.toByteArray();
BufferedImage imag=ImageIO.read(new ByteArrayInputStream(data));
ImageIO.write(imag, "jpg", new File(dirName,"snap.jpg"));//error comes in this line
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Array reading not succesful. Error is: "+e);
}
}
Any help in this regard is well appreciated.
Regards,
Anees