title: Convert image byte[] to a file
body: <p>I am trying to convert an image(png,jpg,tiff,gif) to a File on disk.When I view it after storing it on file, I cannot see the file.</p>
  
  <p>Here is some code I have tried based on other forum discussions:</p>
  
  <pre><code>byte[] inFileName = org.apache.commons.io.FileUtils.readFileToByteArray(new File("c:/test1.png"));
  
  InputStream inputStream = new ByteArrayInputStream(inFilename);
  ..String fileName="test.png";
  Writer writer = new FileWriter(fileName);
  IOUtils.copy(inputStream, writer,"ISO-8859-1");
  </code></pre>
  
  <p>This creates a png file I cannot see.</p>
  
  <p>I tried using ImageIO based on some other discussion but can't get it to work.Any help is appreciated. </p>
  
  <pre><code>    Image inImage = ImageIO.read(new ByteArrayInputStream(inFilename));
  BufferedImage outImage = new BufferedImage(100, 100,
              BufferedImage.TYPE_INT_RGB); 
   OutputStream os = new FileOutputStream(fileName);
  JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
  //encoder.encode(inImage);
  </code></pre>