Java 类javax.mail.internet.SharedInputStream 实例源码

项目:gdata-java-client    文件:MediaStreamSource.java   
public MediaStreamSource(InputStream mediaStream,
                          String mediaType,
                          DateTime lastModified,
                          long contentLength) {

  super(mediaType);
  this.mediaStream = mediaStream;
  this.lastModified = lastModified;
  this.contentLength = contentLength;

  if (mediaStream instanceof SharedInputStream) {
    sharedMediaStreamStart = ((SharedInputStream)mediaStream).getPosition();
  }
}
项目:gdata-java-client    文件:MediaStreamSource.java   
public InputStream getInputStream() {

    // If the underlying stream implements SharedInputStream, then get
    // a new stream so the stream source can be read multiple times.
    InputStream returnStream = (mediaStream instanceof SharedInputStream)
        ? ((SharedInputStream)mediaStream).newStream(sharedMediaStreamStart, -1)
        : mediaStream;

    return returnStream;
  }