不可能把InputStream序列化,InputStream是序列化的实现方式(大概是)。所以把InputStream序列化是没有意义的。既然你已经用rmi了,为什么会有这样的需求 ? 重新审视一下你的思路吧,它有问题。要不说说你用这个InputStream做什么用啊 ?

解决方案 »

  1.   

    传递InputStream肯定是不行的了,我的想法是使用一个实现Remote接口的类,传递这个类来将客户端和服务器端连接起来,如:
    public interface Operator extends Remote{
        int read(byte[])throws RemoteException;
        int write(byte[],int start,int offset)throws RemoteException;
    }
    public class OperatorImpl extends UnicastRemoteObject implements Operator{
       private InputStream is=null;
       private OutputStream os=null;
       public OperatorImpl(InputStream is,OutputStream){
       ....
      }
       public int read(byte[])throws RemoteException{}
        public int write(byte[],int start,int offset)throws RemoteException{}
    }