try{ int max = (Integer) (ois.readObject()); byte[] serial = new byte[max]; for(int i = 0; i < max; i++) serial[i] = (Byte) ois.readObject(); ObjectInputStream oo = new ObjectInputStream(new ByteArrayInputStream(serial)); static BufferedImage a = ImageIO.read(oo); System.out.println(a.toString()); oo.close(); try { File file = new File("Screenshot.jpg"); ImageIO.write(a, "jpg", file); } catch (IOException e) {} }catch(ClassNotFoundException e){}