user169258
user169258

Reputation: 1651

How send image object through socket...?

I want to send image object through socket... Don't want to store image in sender or receivers computer...

Upvotes: 3

Views: 11078

Answers (3)

Martijn Courteaux
Martijn Courteaux

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

Eran Betzalel
Eran Betzalel

Reputation: 4193

Use this serialization for an image object to send it through the socket.

Upvotes: 1

Brian Agnew
Brian Agnew

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

Related Questions