获取Java中InputStream的大小 [英] get size of InputStream in Java

查看:1153
本文介绍了获取Java中InputStream的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加密从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(),尽管不确定即使那些也可以准确地给出我想要的东西,但是在这种情况下,我拥有的是(加密的),我想找到相同的长度,我尝试在Internet上搜索,但是找不到任何有效的解决方案.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆