SharedInputStream (Java EE 5)

Java EE API


javax.mail.internet Interface SharedInputStream

All Known Implementing Classes:
SharedByteArrayInputStream, SharedFileInputStream

public interface SharedInputStream


可供多个 reader 共享的数据所支持的 InputStream 可以实现此接口。这允许此类 InputStream 的用户确定在 InputStream 中的当前位置,并创建表示原 InputStream 数据的子集的新 InputStream。新的 InputStream 将与原 InputStream 访问同一底层数据,不复制数据。

注意,此接口的实现必须确保,在所有共享实例被关闭前,close 方法不关闭任何可能由多个 SharedInputStream 实例共享的底层流。

英文文档:

An InputStream that is backed by data that can be shared by multiple readers may implement this interface. This allows users of such an InputStream to determine the current position in the InputStream, and to create new InputStreams representing a subset of the data in the original InputStream. The new InputStream will access the same underlying data as the original, without copying the data.

Note that implementations of this interface must ensure that the close method does not close any underlying stream that might be shared by multiple instances of SharedInputStream until all shared instances have been closed.

Since:
JavaMail 1.2
Version:
1.5, 07/05/04
Author:
Bill Shannon

Method Summary
 long
 InputStream
 

Method Detail

public long getPosition()
返回 InputStream 中的当前位置,形式为距 InputStream 开头的偏移量。
return 当前位置
英文文档:

getPosition

long getPosition()
Return the current position in the InputStream, as an offset from the beginning of the InputStream.

Returns:
the current position

public java.io.InputStream newStream(long start, long end)
返回表示此 InputStream 数据的子集的新 InputStream,从 start(包括)开始,一直到 end(不包括)结束。start 必须为非负数。如果 end 为 -1,则新流的结束位置与此流相同。返回的 InputStream 也将实现 SharedInputStream 接口。
start 起始位置
end 结束位置 + 1
return 新流
英文文档:

newStream

InputStream newStream(long start,
                      long end)
Return a new InputStream representing a subset of the data from this InputStream, starting at start (inclusive) up to end (exclusive). start must be non-negative. If end is -1, the new stream ends at the same place as this stream. The returned InputStream will also implement the SharedInputStream interface.

Parameters:
start - the starting position
end - the ending position + 1
Returns:
the new stream


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!