This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
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. . .