How to read a very big data using DataInputStream of socket If the data is in String format and having a length of more than 1,00,000 characters.
Also How to write that big data using SocketChannel in java
Thanks Deepak
How to read a very big data using DataInputStream of socket If the data is in String format and having a length of more than 1,00,000 characters.
Also How to write that big data using SocketChannel in java
Thanks Deepak
The problem is that your data is arriving in chunks. Either the packet size is limiting that or maybe DataInputStream has an internal buffer of only 40k. I don't know, but it doesn't matter. Either way, all 1000000 bytes will not arrive at once. So you have to rewrite your program to expect that. You need to read the smaller chunks that you receive and store them in another byte[1000000] variable (keeping track of where your last byte index). Keep looping until you are done reading the socket. Then you can work with your internal variable.