aspose file tools
The moose likes Beginning Java and the fly likes Send content of file over tcp socket Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Send content of file over tcp socket" Watch "Send content of file over tcp socket" New topic
Author

Send content of file over tcp socket

Mads Nielsen
Greenhorn

Joined: Aug 13, 2011
Posts: 28
Hello

First of all thanks to all for helping out with this thread: Speeding up BufferedInputStream

The code i have so far is just copying a file. I want to read the content of the file to a variable and send it over a socket.



So insted of this:


I want to put the content of the file into a variable or array, so i can transfer the file over a socket.

Anyone ?

Kind regards Mads
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Mads Nielsen wrote:I want to put the content of the file into a variable or array, so i can transfer the file over a socket.


I think I should mention that you don't actually need to put the contents of the file into memory to transfer it over a socket. In fact I'm surprised you suggest that, given that you posted some code which works. Just change the part which writes to a FileOutputStream to write to the socket's output stream instead.

(And get rid of the DataInputStream, you don't need it and it just serves to confuse the reader.)
 
 
subject: Send content of file over tcp socket
 
Similar Threads
encrypt data
Speeding up BufferedInputStream and FileOutputStream
Sending a file over socket
Transferring file name then file data over socket
encrypt data in database