javax.mail.util
クラス SharedFileInputStream

java.lang.Object
  上位を拡張 java.io.InputStream
      上位を拡張 java.io.FilterInputStream
          上位を拡張 java.io.BufferedInputStream
              上位を拡張 javax.mail.util.SharedFileInputStream
すべての実装されたインタフェース:
Closeable, SharedInputStream

public final class SharedFileInputStream
extends BufferedInputStream
implements SharedInputStream

SharedFileInputStreammarkreset メソッドをサポートし、 ファイルからデータをバッファリングする BufferedInputStream です。 又、newStream がファイルの部分集合を表す他のストリームを作成するメソッドをサポートします。 RandomAccessFile オブジェクトは、ファイルデータにアクセスする為に使用されます。

導入されたバージョン:
JavaMail 1.4

フィールドの概要
protected  long bufpos
          The file offset that corresponds to the first byte in the read buffer.
protected  int bufsize
          読込みバッファの標準サイズ
protected  long datalen
          The amount of data in this subset of the file.
protected  RandomAccessFile in
          データを含むファイル。
protected  long start
          The file offset of the start of data in this subset of the file.
 
クラス java.io.BufferedInputStream から継承されたフィールド
buf, count, marklimit, markpos, pos
 
コンストラクタの概要
SharedFileInputStream(File file)
          Creates a SharedFileInputStream for the file.
SharedFileInputStream(File file, int size)
          バッファサイズを指定して SharedFileInputStream を作成します。
SharedFileInputStream(String file)
          指定されたファイル名の SharedFileInputStream を作成します。
SharedFileInputStream(String file, int size)
          バッファサイズを指定して SharedFileInputStream を作成します。
 
メソッドの概要
 int available()
          この入力ストリームからブロッキングなしで読む事ができるバイト数を返します。
 void close()
          Closes this input stream and releases any system resources associated with the stream.
protected  void finalize()
          Force this stream to close.
 long getPosition()
          Return the current position in the InputStream, as an offset from the beginning of the InputStream.
 void mark(int readlimit)
          See the general contract of the mark method of InputStream.
 boolean markSupported()
          Tests if this input stream supports the mark and reset methods.
 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).
 int read()
          See the general contract of the read method of InputStream.
 int read(byte[] b, int off, int len)
          Reads bytes from this stream into the specified byte array, starting at the given offset.
 void reset()
          See the general contract of the reset method of InputStream.
 long skip(long n)
          See the general contract of the skip method of InputStream.
 
クラス java.io.FilterInputStream から継承されたメソッド
read
 
クラス java.lang.Object から継承されたメソッド
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

in

protected RandomAccessFile in
データを含むファイル。関連する全ての SharedFileInputStreams に共有されます。


bufsize

protected int bufsize
読込みバッファの標準サイズ


bufpos

protected long bufpos
The file offset that corresponds to the first byte in the read buffer.


start

protected long start
The file offset of the start of data in this subset of the file.


datalen

protected long datalen
The amount of data in this subset of the file.

コンストラクタの詳細

SharedFileInputStream

public SharedFileInputStream(File file)
                      throws IOException
Creates a SharedFileInputStream for the file.

パラメータ:
file - ファイル
例外:
IOException

SharedFileInputStream

public SharedFileInputStream(String file)
                      throws IOException
指定されたファイル名の SharedFileInputStream を作成します。

パラメータ:
file - ファイル
例外:
IOException

SharedFileInputStream

public SharedFileInputStream(File file,
                             int size)
                      throws IOException
バッファサイズを指定して SharedFileInputStream を作成します。

パラメータ:
file - ファイル
size - バッファサイズ
例外:
IllegalArgumentException - size0 以下の場合
IOException

SharedFileInputStream

public SharedFileInputStream(String file,
                             int size)
                      throws IOException
バッファサイズを指定して SharedFileInputStream を作成します。

パラメータ:
file - ファイル
size - バッファサイズ
例外:
IllegalArgumentException - size0 以下の場合
IOException
メソッドの詳細

read

public int read()
         throws IOException
See the general contract of the read method of InputStream.

オーバーライド:
クラス BufferedInputStream 内の read
戻り値:
the next byte of data, or -1 if the end of the stream is reached.
例外:
IOException - 入出力例外が発生した場合

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Reads bytes from this stream into the specified byte array, starting at the given offset.

This method implements the general contract of the corresponding read method of the InputStream class.

オーバーライド:
クラス BufferedInputStream 内の read
パラメータ:
b - destination buffer.
off - offset at which to start storing bytes.
len - maximum number of bytes to read.
戻り値:
the number of bytes read, or -1 if the end of the stream has been reached.
例外:
IOException - 入出力例外が発生した場合

skip

public long skip(long n)
          throws IOException
See the general contract of the skip method of InputStream.

オーバーライド:
クラス BufferedInputStream 内の skip
パラメータ:
n - the number of bytes to be skipped.
戻り値:
the actual number of bytes skipped.
例外:
IOException - 入出力例外が発生した場合

available

public int available()
              throws IOException
この入力ストリームからブロッキングなしで読む事ができるバイト数を返します。

オーバーライド:
クラス BufferedInputStream 内の available
戻り値:
この入力ストリームからブロッキングなしで読む事ができるバイト数
例外:
IOException - 入出力例外が発生した場合

mark

public void mark(int readlimit)
See the general contract of the mark method of InputStream.

オーバーライド:
クラス BufferedInputStream 内の mark
パラメータ:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
関連項目:
reset()

reset

public void reset()
           throws IOException
See the general contract of the reset method of InputStream.

If markpos is -1 (no mark has been set or the mark has been invalidated), an IOException is thrown. Otherwise, pos is set equal to markpos.

オーバーライド:
クラス BufferedInputStream 内の reset
例外:
IOException - if this stream has not been marked or if the mark has been invalidated.
関連項目:
mark(int)

markSupported

public boolean markSupported()
Tests if this input stream supports the mark and reset methods. The markSupported method of SharedFileInputStream returns true.

オーバーライド:
クラス BufferedInputStream 内の markSupported
戻り値:
a boolean indicating if this stream type supports the mark and reset methods.
関連項目:
InputStream.mark(int), InputStream.reset()

close

public void close()
           throws IOException
Closes this input stream and releases any system resources associated with the stream.

定義:
インタフェース Closeable 内の close
オーバーライド:
クラス BufferedInputStream 内の close
例外:
IOException - 入出力例外が発生した場合

getPosition

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

定義:
インタフェース SharedInputStream 内の getPosition
戻り値:
現在の位置

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.

定義:
インタフェース SharedInputStream 内の newStream
パラメータ:
start - 開始位置
end - 終了位置 + 1
戻り値:
新しいストリーム

finalize

protected void finalize()
                 throws Throwable
Force this stream to close.

オーバーライド:
クラス Object 内の finalize
例外:
Throwable