I am currently writing a programming a webserver, I am working on the HTTP PUT method. When the client is connect and he types something like this:
PUT /newfile.txt HTTP/1.1
Host: myhost
BODY This text is what has to be written to the new created file
I want to be able to write the BODY of the client request into the created file.
This is what I have to far, it work but after I press enter it stays there.
InputStream is = conn.getInputStream();
OutputStream fos = Files.newOutputStream(file);
int count = 0;
int n = 10;
while (count < n) {
int b = is.read();
if (b == -1) break;
fos.write(b);
++count;
}
fos.close();
conn.close();