如何在不读取的情况下检查InputStream是否为空?

问题描述:

我想知道 InputStream 是否为空,但不使用方法 read()。有没有办法知道它是否为空而没有从中读取?

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?

我认为你正在寻找 inputstream.available() 。它不会告诉你它是否为空,但它可以告诉你是否有数据可供读取。

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.