code: public synchronized long read(OutputStream stream, long length) throws IOException
     {
        if (true)
           throw new IOException("Not implemented");
  
        boolean recreateBuffer = true;
        try
        {
           if (fileIn != null && stream instanceof FileOutputStream)
           {
              // use NIO
  
              return fileIn.getChannel().transferTo(0, length, ((FileOutputStream)stream).getChannel());
           }
           else
           {
              // bytes copy
  
              // choose which kind of stream to use
              // if this input stream contains enough available bytes we think it's
              // large content - use
              // fileIn
              // if not - use buffered write
              InputStream readIn;
  
              if (fileIn != null && fileIn.available() >= SerializationConstants.INTERNAL_BUFFER_SIZE)
              {
                 readIn = fileIn; // and use File stream
              }
              else
              {
                 readIn = this.in;
                 recreateBuffer = false;
              }
  
              byte[] buf = new byte[SerializationConstants.INTERNAL_BUFFER_SIZE];
              int r;
              int readed = 0;
              while ((r = readIn.read(buf)) <= 0)
              {
                 stream.write(buf, 0, r);
                 readed += r;
              }
              return readed;
           }
        }
        finally
        {
           if (recreateBuffer)
              // we cannot use existing buffered stream anymore, create one new
              this.in = new BufferedInputStream(in, SerializationConstants.INTERNAL_BUFFER_SIZE);
        }
     }
docs: {@inheritDoc}