I got this client application that sends my file fully to server. But I want it to send file in chunks. Here is my client code:
byte[] fileLength = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
dis.readFully(fileLength, 0, fileLength.length);
OutputStream os = socket.getOutputStream();
//Sending size of file.
DataOutputStream dos = new DataOutputStream(os);
dos.writeLong(fileLength.length);
dos.write(fileLength, 0, fileLength.length);
dos.flush();
socket.close();
So how can I make client send my file in chunks? Thanks in advance.
Try to send the file from client in parts, something like
and reassemble it on the server.
Apache Commons supports streaming, so it may help.