title: Convert byte array into a file without writing the file to a disk
body: <p>I have saved icon size images in a mysql database in bytes, now, what I need to do is retrieve those file bytes from the database and show those images in a swing application, I have a method which gets the bytes from the database and convert it back to a file but I have to write that file in to the disk</p>
  
  <p>this is my method,</p>
  
  <pre><code>public void downloadFile(int FamerId) throws Exception {
    String sql = "SELECT * FROM images WHERE famer_id=?";
    Connection con = JDBCConnectionPool.getInstance().checkOut();
    PreparedStatement ps = con.prepareStatement(sql);        
    ps.setInt(1, FamerId);
    ResultSet resultSet = ps.executeQuery();
  
    int count = 0;
  
    while (resultSet.next()) {
      ByteArrayInputStream bais;
      ObjectInputStream inputStream;
  
      bais = new ByteArrayInputStream(resultSet.getBytes("image"));
      inputStream = new ObjectInputStream(bais);
      SaveFile sf = (SaveFile) inputStream.readObject();
      FileOutputStream out = new FileOutputStream("fileLocation/" + resultSet.getString("image_name"));
      byte[] bytes = sf.getArray();
  
      int c = 0;
      while (c &lt; bytes.length) {
        out.write(bytes[c]);
        c++;
      }
  
      out.close();
      inputStream.close();
      bais.close();            
      JDBCConnectionPool.getInstance().checkOut();
    }
  }
  </code></pre>
  
  <p>but this method doesn't give what I need, please assist me.</p>