JavaTM 2 Platform
Standard Ed. 6

javax.imageio.stream
类 FileCacheImageInputStream

java.lang.Object
  继承者 javax.imageio.stream.ImageInputStreamImpl
      继承者 javax.imageio.stream.FileCacheImageInputStream
所有已实现的接口:
DataInput, ImageInputStream

public class FileCacheImageInputStream
extends ImageInputStreamImpl

从常规 InputStream 获取其输入的 ImageInputStream 的实现。使用文件缓存以前读取的数据。


字段摘要
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的字段
bitOffset, byteOrder, flushedPos, streamPos
 
构造方法摘要
FileCacheImageInputStream(InputStream stream, File cacheDir)
          构造一个将从给定 InputStream 进行读取的 FileCacheImageInputStream
 
方法摘要
 void close()
          关闭此 FileCacheImageInputStream,关闭并移除缓存文件。
protected  void finalize()
          在垃圾回收前结束此对象。
 boolean isCached()
          返回 true,因为此 ImageInputStream 为了允许逆向查找而缓存了数据。
 boolean isCachedFile()
          返回 true,因为此 ImageInputStream 维护文件缓存。
 boolean isCachedMemory()
          返回 false,因为此 ImageInputStream 不维护主存缓存。
 int read()
          从流中读取单个字节,并以 int(0 到 255 之间)形式返回该字节。
 int read(byte[] b, int off, int len)
          从流中读取至多 len 个字节,并将其存储到 b 中(从 off 索引处开始)。
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的方法
checkClosed, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, length, mark, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytes
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

FileCacheImageInputStream

public FileCacheImageInputStream(InputStream stream,
                                 File cacheDir)
                          throws IOException
构造一个将从给定 InputStream 进行读取的 FileCacheImageInputStream

将临时文件用作缓存。如果 cacheDir 不为 null 且是一个目录,则在该处创建文件。如果为 null,则使用与系统相关的默认临时文件目录(有关详细资料,请参阅 File.createTempFile 的文档)。

参数:
stream - 要从其进行读取的 InputStream
cacheDir - 一个指示缓存文件创建目录的 File;或 null,指示使用系统目录。
抛出:
IllegalArgumentException - 如果 streamnull
IllegalArgumentException - 如果 cacheDir 不为 null 但不是一个目录。
IOException - 如果无法创建缓存文件。
方法详细信息

read

public int read()
         throws IOException
从类 ImageInputStreamImpl 复制的描述
从流中读取单个字节,并以 int(0 到 255 之间)形式返回该字节。 如果到达 EOF,则返回 -1

子类必须提供此方法的实现。子类实现在退出前应该更新流位置。

在发生读取前,流中的位偏移量必须被重置为 0。

指定者:
接口 ImageInputStream 中的 read
指定者:
ImageInputStreamImpl 中的 read
返回:
流中下一个字节的值;如果到达 EOF,则返回 -1
抛出:
IOException - 如果流已经被关闭。

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
从类 ImageInputStreamImpl 复制的描述
从流中读取至多 len 个字节,并将其存储到 b 中(从 off 索引处开始)。如果由于到达流末尾而没有读取任何字节,则返回 -1

在发生读取前,流中的位偏移量必须被重置为 0。

子类必须提供此方法的实现。子类实现在退出前应该更新流位置。

指定者:
接口 ImageInputStream 中的 read
指定者:
ImageInputStreamImpl 中的 read
参数:
b - 用来接收写入的字节数组。
off - b 中要写入的起始位置。
len - 要读取的最大字节数。
返回:
实际读取的字节数;或者 -1,指示 EOF。
抛出:
IOException - 如果发生 I/O 错误。

isCached

public boolean isCached()
返回 true,因为此 ImageInputStream 为了允许逆向查找而缓存了数据。

指定者:
接口 ImageInputStream 中的 isCached
覆盖:
ImageInputStreamImpl 中的 isCached
返回:
true
另请参见:
isCachedMemory(), isCachedFile()

isCachedFile

public boolean isCachedFile()
返回 true,因为此 ImageInputStream 维护文件缓存。

指定者:
接口 ImageInputStream 中的 isCachedFile
覆盖:
ImageInputStreamImpl 中的 isCachedFile
返回:
true
另请参见:
isCached(), isCachedMemory()

isCachedMemory

public boolean isCachedMemory()
返回 false,因为此 ImageInputStream 不维护主存缓存。

指定者:
接口 ImageInputStream 中的 isCachedMemory
覆盖:
ImageInputStreamImpl 中的 isCachedMemory
返回:
false
另请参见:
isCached(), isCachedFile()

close

public void close()
           throws IOException
关闭此 FileCacheImageInputStream,关闭并移除缓存文件。但不关闭源 InputStream

指定者:
接口 ImageInputStream 中的 close
覆盖:
ImageInputStreamImpl 中的 close
抛出:
IOException - 如果发生错误。

finalize

protected void finalize()
                 throws Throwable
在垃圾回收前结束此对象。调用 close 方法来关闭所有开启的输入源。不应该从应用程序代码调用此方法。

覆盖:
ImageInputStreamImpl 中的 finalize
抛出:
Throwable - 如果在超类终止过程中发生错误。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only