How to read huge data on a socket and also write to socketchannel
1 answer
The problem is your data is coming in chunks. Either the packet size is limited or the DataInputStream has an internal buffer of only 40k. I don't know, but it doesn't matter. In any case, all 1,000,000 bytes will not arrive at once. Therefore, you must rewrite your program to expect this. You need to read the smaller chunks you get and store them in another byte [1,000,000] variable (keeping track of where your last byte index is). Continue looping until you've finished reading the socket. Then you can work with your internal variable.
+1
Chris janicki
a source
to share