获取Java中InputStream的大小 [英] get size of InputStream in Java
问题描述
我正在尝试加密从FileItem.getInputStream();
获得的InputStream
,并且我想知道加密流的长度.
I am trying to encrypt an InputStream
which I am getting from FileItem.getInputStream();
and I want to know the encrypted stream's length.
如果它是简单的FileInputStream
,则我可以尝试File#length()
或FileInputStream#getChennal().size()
,尽管不确定即使那些也可以准确地给出我想要的东西,但是在这种情况下,我拥有的是
If it would be a simple FileInputStream
, I could have tried File#length()
or FileInputStream#getChennal().size()
though not sure even those would have given me exactly what I want, but, in this case what I have is an InputStream
(the encrypted one) and I want to find length of the same, I tried searching on Internet but there I could not find any efficient solution to that.
请帮助
推荐答案
您可以在InputStream中输出内容并获取长度
You can output whats in InputStream and get the length
ObjA = new ObjA;
while( more message to read ){
ObjA = inputStreamObj.read();
}
System.out.println(ObjA.length());
这篇关于获取Java中InputStream的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!