我正在开发一个应用程序,其中从服务器下载文件是加密的。在应用程序中,我试图打开存储在内部存储中的加密文件来解密它:
ObjectInputStream ois = new ObjectInputStream(new CipherInputStream(context.openFileInput("filename"), cipher));
String result = (String) ois.readObject();
但获得例外:
java.io.StreamCorruptedException
在这种情况下,此错误意味着什么,以及如何解决?
感谢。
答案 0 :(得分:0)
Thrown when control information that was read from an object stream violates internal consistency checks.
From this helpful google search:
Essentially, what happens is that, somehow or other, the writing and the reading get "out of kilter". Here are a couple of ways it can happen:
Forgetting to close the ObjectOutputStream that wrote the data (or
closing the wrong stream)
Forgetting to check the return value of InputStream.read().