Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if DataInputStream has content

Is there a way to ask a DataInputStream, if it has content to read? .readByte() will just hang it, waiting for a byte to be read :( Or do I always have to send a Dummy-Byte, to make sure it always sees something?

like image 995
Pwnie2012 Avatar asked Jan 19 '14 12:01

Pwnie2012


1 Answers

dis.available();

Returns: an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.

Is this what you looking for?

also check answers here. You might get even more informations. "available" of DataInputStream from Socket

like image 56
Tomas Bisciak Avatar answered Sep 25 '22 21:09

Tomas Bisciak