my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Buffered Images to Input Streams Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Buffered Images to Input Streams" Watch "Buffered Images to Input Streams" New topic
Author

Buffered Images to Input Streams

Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
Hi - I'm trying to write the contents of a BufferedImage for reading by another class that requires an InputStream. The only way I have been able to figure out how to do this so far is to write the image to a temporary file and then read it into the object stream (note the image is created during run-time so I cannot just read the image file in since it does not exist until I write it out). Is there an easier way to do this where I don't have to actually write the file out?

Thanks.
Jeff
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Well you could use ByteArrayInputStream and ByteArrayOutputStream.


bitguru blog
Jeff Storey
Ranch Hand

Joined: Oct 09, 2006
Posts: 118
I'll give that a try. Thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Buffered Images to Input Streams
 
Similar Threads
how to read in text and images and write them out?
difficulty storing BufferedImage in Oracle BLOB field
How to write an imge into a file
BufferedImage to File Object
getting unix like file information the java way