SharedByteArrayInputStream (Java EE 5)

Java EE API


javax.mail.util Class SharedByteArrayInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.ByteArrayInputStream
          extended by javax.mail.util.SharedByteArrayInputStream
All Implemented Interfaces:
Closeable, SharedInputStream

public class SharedByteArrayInputStream
extends ByteArrayInputStream
implements SharedInputStream

Extends: java.io.InputStream > java.io.ByteArrayInputStream
Implements: SharedInputStream

实现 SharedInputStream 接口的 ByteArrayInputStream,允许在多个 reader 之间共享底层 byte 数组。
英文文档:

A ByteArrayInputStream that implements the SharedInputStream interface, allowing the underlying byte array to be shared between multiple readers.

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

Field Summary
protected  int
 
Fields inherited from class java.io.ByteArrayInputStream
 
Constructor Summary
 
Method Summary
 long
 InputStream
 
Methods inherited from class java.io.ByteArrayInputStream
 
Methods inherited from class java.io.InputStream
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

start

protected int start
Position within shared buffer that this stream starts at.

Constructor Detail

public SharedByteArrayInputStream(byte[] buf)
创建一个表示整个 byte 数组的 SharedByteArrayInputStream。
buf byte 数组
英文文档:

SharedByteArrayInputStream

public SharedByteArrayInputStream(byte[] buf)
Create a SharedByteArrayInputStream representing the entire byte array.

Parameters:
buf - the byte array


public SharedByteArrayInputStream(byte[] buf, int offset, int length)
创建一个表示部分 byte 数组(从 offset 开始的 length 个字节)的 SharedByteArrayInputStream。
buf byte 数组
offset byte 数组中距离第一个字节的偏移量
length 要包含的字节数
英文文档:

SharedByteArrayInputStream

public SharedByteArrayInputStream(byte[] buf,
                                  int offset,
                                  int length)
Create a SharedByteArrayInputStream representing the part of the byte array from offset for length bytes.

Parameters:
buf - the byte array
offset - offset in byte array to first byte to include
length - number of bytes to include

Method Detail

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

getPosition

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

Specified by:
getPosition in interface SharedInputStream
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

public 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.

Specified by:
newStream in interface SharedInputStream
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!