File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Buffered Images to Input Streams" Watch "Buffered Images to Input Streams" New topic

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?

Brian Cole
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.
I agree. Here's the link:
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