Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Sending image from 1 computer to another.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not sure this is the correct forum to post my query.
Query is related to Networking and I/O.
I have a need to send an image from one computer to another using Java.
This image should be displayed right on the receipient's desktop.
We know that if we type "net send "computer_name" "message" in Start-->Run, the "message" is displayed on the machine-computer_name", which is connected to your machine.
I need the same kind of functionality for image. I need to send an image to another computer and display it on the receipient's desktop.
I think to pass an image, I will have to convert the image to byte array and then on the receipent's end convert the byte array to image.
I am not sure how to code this. I might sound quite ignorant. I mean how do I code this logic?
I need some guidance.
Thanks.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many different ways in Java to have one computer talk to another. You can deal with low level sockets, URLs, or with RMI.
For transferring an image, you can also use a variety of methods. You most likely will want to deal with buffered streams wrapping a byte array stream. Or you could do it via file streams.
If you want to just do direct communication and not go through the steps needed for RMI, you probably want to use a Socket, and get the input and output streams from that object to read/write the file.
I'm going to send this to the Sockets and Protocols forum, since finding out how to communicate between the two computers is your first priority.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out this sample code I wrote for a similar problem. Replace the sample data String with a BufferedImage and you should find it fairly easy to use Object*putStream to send it across the network. Of course in your case, the long-lived "server" process needs to be on the "client" machine so it can display the image. . .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic