Reputation: 1651
I want to send image object through socket... Don't want to store image in sender or receivers computer...
Upvotes: 3
Views: 11078
Reputation: 68847
Use this method:
ImageIO.write(RenderedImage, String, OutputStream)
Use in your situation:
Sender
BufferedImage image = ....;
ImageIO.write(image, "PNG", socket.getOutputStream());
Receiver
BufferedImage image = ImageIO.read(socket.getInputStream());
Upvotes: 10
Reputation: 4193
Use this serialization for an image object to send it through the socket.
Upvotes: 1
Reputation: 272217
So what have you tried ?
This is a tutorial on client/server communication using Java. This reads from stdin, but in your instance you should probably provide an InputStream on your image object.
Upvotes: 1