我做了一個應用程序,可以安全地在系統之間傳輸文件... 所有工作正常...除了在接收端。它示出了異常:java.lang.ClassCastException:[B不能轉換爲java.io.ObjectStreamClass
Exception in thread "New Connection" java.lang.ClassCastException: [B cannot be cast to java.io.ObjectStreamClass
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at network.FileDownload.secureFileReceive(FileDownload.java:341)
at network.FileDownload.run(FileDownload.java:240)
at java.lang.Thread.run(Unknown Source)
客戶端程序的(FileDownload),在該發生異常是
String bb = security.decrypt((int[][]) input1.readObject());
byte[] buf = bb.getBytes("ISO-8859-1");
線線的服務器側是
output1.writeObject(security.encrypt(new String(buf,"ISO-8859-1")));
在此,安全類有security.encrypt()
需要String並返回int [] []。 security.decrypt
反之亦然。 請幫幫我。
'output1'對象的類型是什麼? –
其ObjectOutputStream –
爲什麼你把它轉換成int [] []?你不能staright去調用類似output1.writeObject((security.encrypt(new String(buf,「ISO-8859-1」));? – Lokesh