• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Send content of file over tcp socket

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28370
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic