jQuery in Action, 2nd edition
The moose likes Java in General and the fly likes How to convert a datagramPacket to a file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to convert a datagramPacket to a file ?" Watch "How to convert a datagramPacket to a file ?" New topic
Author

How to convert a datagramPacket to a file ?

kaushik saha
Greenhorn

Joined: Sep 22, 2005
Posts: 18
I have a UDP client program .In my program i want to send a file to the server.I have created a GUI form .I use JFileChooser to select the file.
after Choosing it i send the file to the UDP server.
But in the server i receive the file in the Datagrampacket.After that i want to save the file in the server side. How i convert the DatagramPacket
to file? And the file will be saved in the server side with the specific extension that will be sent by the client.

Please help me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35446
    
    9
You can use the getDate() method to get at the bytes contained in the datagram. You'll need to collect all the bytes, and then write them to a file. The file name needs to be sent especially, maybe first thing in the transmission, separated from the actual file data by some special character.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to convert a datagramPacket to a file ?
 
Similar Threads
Communicate 2 android in 2 emulator
Audio in Java
how to develope tcp protocol in socket connetion
Android Emulator as server in Socket communication
how to send sound buffer in UDP