我用 FileInputStream传递,
老报错:
ava.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.FileInputStream
老报错:
ava.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.FileInputStream
public class HelloClient implements Serializable我服务器,客户端 现在都加了,还是不行
用sock自己写吧:
发送:
out = new BufferedOutputStream(sock.getOutputStream());
in = new BufferedInputStream(sock.getInputStream());
fis = new FileInputStream(file);
byte[] b = new byte[5120];
for(int tmp=0;(tmp=fis.read(b))!=-1; )
{
out.write(b,0,tmp);
}
if(fis!=null)fis.close();
if(out!=null)out.close();
if(sock!=null)sock.close();
fs = new BufferedOutputStream(new FileOutputStream(savePath));
out = new BufferedOutputStream(sock.getOutputStream());
in = new BufferedInputStream(sock.getInputStream());
System.out.println("start to recv....");
byte[] b = new byte[5120];
long recvSize = 0;
for (int tmp = -1; (tmp = in.read(b)) != -1;) {
fs.write(b, 0, tmp);
} fs.close();
out.close();
in.close();
sock.close();