I want to read from a client's inputstream in two different ways:
1: Use Scanner over the inputstream to read strings.
2: Use the InputStream object itself to read a file with a buffer.
At first, I want to read a text, that gives me the name and size of the File, in my case: "file:name:...", "file:size:...".
When I have this information, the InputStream should actually read the file. The problem is, that I try to read the file in the "scanner.hasNextLine()"-loop with the InputStream object but this causes the InputStream.read() method to return -1 or EOS. I have brought the problem to a minimal size so you just have to answer me this question:
Why does the read-method return -1 here:
if (scanner.hasNextLine()) {
System.out.println(inputstream.read());
}