This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 19684
    
  20

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
 
 
subject: Image into serializable object?