File file = new File ("temp.txt");
FileInputStream fin = new FileInputStream(file);
ObjectInputStream oin = new ObjectInputStream(fin);
不知道你说的  “同时将另一个对象加到这个流中“什么意思?

解决方案 »

  1.   

    就是返回的是一个流
    fin 和oin 都需要返回 一个 in
    怎么做?
      

  2.   

    是不是要使用pipe来转化一下?
    先都写到管道output,然后再把pipedInput返回
      

  3.   

    这样清楚了?
    public InputStream getStream()
    {
      File file = new File ("temp.txt");
      FileInputStream fin = new FileInputStream(file);
      ObjectInputStream oin = new ObjectInputStream(fin);
      String a = “new String”;
       .............  return (ObjectInputSteam)inputStream;   //该输入流包含了oin和a的内容}
      

  4.   

    用BufferedInputStream和BufferedOutputStream来实现,一个一个往里写,应该可以吧
      

  5.   

    问题就是如何将别的输入流一个一个加入BufferedInputStream?
      

  6.   

    将你需要的多个流源读到一个临时文件你然后用这个临时文件来new一个输入流不久完事了。
      

  7.   

    是不是这样:
    public InputStream getStream()
    {
      File file = new File ("temp.txt");
      FileInputStream fin = new FileInputStream(file);
      ObjectInputStream oin = new ObjectInputStream(fin);
      String a = “new String”;  ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(bos);
      oos.writObject(a);
      byte[] objData = bos.toByteArray();
      
      ByteArrayInputStream bis = new ByteArrayInputStream(objData);
      ObjectInputStream ois = new ObjectIpuStream(bis);  return new SequenceInputStream(ois, oin);
    }
      

  8.   

    return new ObjectInputStream(new SequenceInputStream(ois, oin));
      

  9.   

    faint
    那可以
     ObjectInputStream ois = new ObjectInputStream(new StringBufferInputStream(a));不知道行不行?
      

  10.   

    是有问题,这样就可以了:
    public InputStream getStream()
    {
        File file = new File ("temp.txt");
        FileInputStream fin = new FileInputStream(file);
        ObjectInputStream oin = new ObjectInputStream(fin);
        String a = “new String”;    ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(a);
        try
        {
            while(true)
                oos.writeObject(oin.readObject());
        }
        catch(EOFException e)
        {
        }
        oos.flush();
        oin.close();
        ObjectInputStream result = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
        return result;
    }