There is a small client-server program, clients can make requests to get a list of files and download them. Now the program normally writes only text files, uses DataInputStream and DataOutputStream . ( FileInputStream and OutputStream respectively).

All the contents of the files are read by the usual FileInputStream , but before they are sent, they are written to a string, which is not good. Which threads are best used to read content records? Provided that we do not know with what type of file will have to work.

And in what form is it better to transfer data via tcp / ip?

Closed due to the fact that off-topic participants zRrr , cheops , aleksandr barakin , D-side , Athari Jun 20, '16 at 19:39 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - zRrr, cheops, aleksandr barakin, D-side, Athari
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Read the usual BufferedInputStream in byte[] , then send bytes to the socket. Nothing complicated. - Nofate
  • So I tried to do it, now the malformed input around byte 0 pops up - Archelite
  • Do you understand that without an example of inoperative code it will be difficult for you to help? - Nofate
  • The person, I will tell, anybody does not transfer the normal data through a flow of objects. This is 1. very slowly, 2. I throw a bunch of garbage through a socket, and then additional costs for cpu, the Internet. - Denis Kotlyarov
  • And what about File streams have up to socket streams? There's a regular set of bytes from the InputStream and sending data through the OutputStream. Do something else. - Denis Kotlyarov

0