• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

BufferedImage from FileOutputStream

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
i want to get a BufferedImage but I have a FileOutputStream Object with me. Can anyone tell how do I get it?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A FileOutputStream is for writing to a file. Did you mean you have a FileInputStream object, for reading from a file?

The easiest way to read an image from a file is using the ImageIO API:
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jesper,
Thanks for your reply adn apology if I was not clear in my question.
I have a FileOutputStream object adn I want to convert it to a BufferedImage as the new encode() takes BufferedImage instead of FileOutputStream (that was used earlier).

FileOutputStream fos = null;
fos = new FileOutputStream(actualImagePath,false);
if (fos != null) {customBean.encode(<BufferredImageRequired> ;
I cannot change the approach to maintain backward compatibility.

Is there a way we can do this?
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not possible. Can you explain more about the project you're working on? Do you understand exactly what the encode(...) method is supposed to do in the context of the project?
reply
    Bookmark Topic Watch Topic
  • New Topic