我用 FileInputStream传递,
老报错:
ava.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.FileInputStream

解决方案 »

  1.   

    public class HelloServer extends UnicastRemoteObject implements Hello,Serializable 
    public class HelloClient implements Serializable我服务器,客户端 现在都加了,还是不行
      

  2.   

    不用这样传递文件吧?
    用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();
      

  3.   

    sock = new Socket(addr, port);
    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();