0
當我嘗試讀取存儲在文件中的壓縮對象時,顯然一切似乎都正常,我可以獲取保存的值,但在日誌中始終顯示此錯誤當我嘗試讀取文件中的壓縮對象時,發生StreamCorruptedException
java.io.StreamCorruptedException
W/System.err﹕ at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:2067)
W/System.err﹕ at java.io.ObjectInputStream.<init>(ObjectInputStream.java:372)
我不understod如何解決它
我使用它來裝載:
ObjectInputStream inputStream = null;
try {
inputStream = new ObjectInputStream(cipherInputStream);
} catch (IOException e) {
e.printStackTrace();
}
if (inputStream != null) {
try {
myDecipheredObject = (Serializable) inputStream.readObject();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
和TH是存儲
ObjectOutputStream outputStream = null;
try {
outputStream = new ObjectOutputStream(cipherOutputStream);
outputStream.writeObject(object);
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (RuntimeException e) {
e.printStackTrace();
}
在這條線的負載方法發生錯誤
inputStream = new ObjectInputStream(cipherInputStream);
您可以顯示您用來創建密碼的輸入和輸出流的代碼嗎? – fge
我使用與其他各種方法中使用的密碼相同的代碼,但此錯誤僅在此發生,所以我幾乎可以確定問題的原因是另一種。 – AndreaF