如何在不读取的情况下检查InputStream是否为空? [英] How can I check if an InputStream is empty without reading from it?
本文介绍了如何在不读取的情况下检查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.
这篇关于如何在不读取的情况下检查InputStream是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文