我制作了一个可以在系统之间安全传输文件的应用程序......一切正常......除了接收端。它显示了一个
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
反之亦然。请帮我。