It sounds like you are not starting to write to disk until you read the last byte from HTTP. This has two undesirable effects:
. , . , 201.
API HTTP , , API.
, Java Servlet API InputStream :
InputStream content = request.getInputStream();
OutputStream out = new FileOutputStream("content.txt");
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
, InputStream , TCP (*). . , , . , .
(*) . . ,