• Post Reply Bookmark Topic Watch Topic
  • New Topic

Send content of file over tcp socket  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!