It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Image into serializable object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Image into serializable object?" Watch "Image into serializable object?" New topic
Author

Image into serializable object?

sai pabb
Greenhorn

Joined: Sep 01, 2010
Posts: 9
Hello,

I'm new to Java images/IO. I've an api which gives me Image object, All I need to do is save the Image onto the server. So, Applet gets an image from the sanner api, the api returns Image object. I need to serialize this and send this to the servlets. Now the servlet has to save this onto the filesystem. Could you help me through this process?
C Popp
Greenhorn

Joined: Aug 08, 2007
Posts: 14
You can try wrapping the Image object in an ImageIcon object which does implement Serializable.

http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/ImageIcon.html
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Or use ImageIO to turn the image into a byte[]. Use ByteArrayOutputStream and ByteArrayInputStream as intermediaries.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image into serializable object?
 
Similar Threads
problem with the image field
overlay jpeg with text
Applet Servlet Serialized Object
Saving an image into oracle
Image or ImageIcon?