DataInputStream dis = new DataInputStream(con.getInputStream());
while(dis.available() > 0 {
long mydata = dis.readLong();
// read more data for a record
...
workOnOneRecord();
}
I read multiple binary variable size records of data and EOF would happen at the end of one set of data.
I understand this available()
is wrong, if data arrives in chunks? (Could happen that there's more data pending, sender has not yet closed the stream, etc. ?)
This is for reading over a network connection, there's no filesize or similar, known in advance.
I'd like to reserve the EOFException to an error case, running into EOF unexpectedly. Is there something like while (! dis.EOF() ) { ... }
before the next read would return EOF ?