title: Conversion between InputStream and BufferedImage
body: <p>I want to convert an InputStream object representing an image file to a BufferedImage object and after performing some operations on the BufferedImage convert it back to an InputStream so that it can be written to disk.I dont want to create a file object on disk first in order to prevent additional IO overhead.</p>
  
  <p>I think i can do the following to convert a BufferedImage to InputStream</p>
  
  <pre><code>ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  ImageIO.write(image,fileExtension, outputStream);
  InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
  </code></pre>
  
  <p>Is that correct ?. Also, i have the following two questions</p>
  
  <ol>
  <li>How to get BufferedImage object from an InputStream object</li>
  <li>Can i get the filesize directly from the InputStream object ?</li>
  </ol>
  
  <p>Some example would really help</p>
  
  <p>Thank You</p>