javainputstream

How can I check if an InputStream is empty without reading from it?


I want to know if an InputStream is empty, but without using the method read(). Is there a way to know if it's empty without reading from it?


Solution

  • I think you are looking for inputstream.available(). It does not tell you whether its empty but it can give you an indication as to whether data is there to be read or not.