所有类


javax.imageio.stream
类 FileCacheImageOutputStream

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

public class FileCacheImageOutputStream
   
   
   
   
   
extends ImageOutputStreamImpl

将输出写入常规 OutputStream 中的 ImageOutputStream 的实现。在将数据刷新到输出流前用于缓存数据的文件。


字段摘要
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的字段
bitOffset, byteOrder, flushedPos, streamPos
 
构造方法摘要
FileCacheImageOutputStream(OutputStream stream, File cacheDir)
          构造一个将向给定 outputStream 进行写入的 FileCacheImageOutputStream
 
方法摘要
 voidclose()
          关闭此 FileCacheImageOututStream
 voidflushBefore(long pos)
          丢弃所指示部分之前的流初始部分。
 booleanisCached()
          返回 true,因为此 ImageOutputStream为了允许逆向查找而缓存了数据。
 booleanisCachedFile()
          返回 true,因为此 ImageOutputStream 维护文件缓存。
 booleanisCachedMemory()
          返回 false,因为此 ImageOutputStream 不维护主存缓存。
 longlength()
          返回 -1L,指示流的长度未知。
 intread()
          从流中读取单个字节,并以整数(0 到 255 之间)形式返回该字节。
 intread(byte[] b, int off, int len)
          从流中读取至多 len 个字节,并将其存储到 b 中(从 off 索引处开始)。
 voidseek(long pos)
          设置当前流位置并将位偏移量重置为 0。
 voidwrite(byte[] b, int off, int len)
          将数组 b 中的 len 个字节按顺序写入输出流。
 voidwrite(int b)
          将参数 b 的八个低位写入输出流。
 
从类 javax.imageio.stream.ImageOutputStreamImpl 继承的方法
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTF
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的方法
checkClosed, finalize, flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, 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, setBitOffset, setByteOrder, skipBytes, skipBytes
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 javax.imageio.stream.ImageInputStream 继承的方法
flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, 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, setBitOffset, setByteOrder, skipBytes, skipBytes
 

构造方法详细信息

FileCacheImageOutputStream

public FileCacheImageOutputStream(OutputStream stream,
                                  File cacheDir)
                           throws IOException
构造一个将向给定 outputStream 进行写入的 FileCacheImageOutputStream

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

参数:
stream - 将写入到的 OutputStream
cacheDir - 一个指示缓存文件创建目录的 File;或 null,指示使用系统目录。
抛出:
IllegalArgumentException - 如果 streamnull
IllegalArgumentException - 如果 cacheDir 不为 null 但不是一个目录。
IOException - 如果无法创建缓存文件。
方法详细信息

read

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

在进行读取前,将流中的位偏移量重置为零。

指定者:
接口 ImageInputStream 中的 read
指定者:
ImageInputStreamImpl 中的 read
返回:
流中的 int 形式的字节值;或者 -1,指示 EOF(文件结束标记)。
抛出:
IOException - 如果发生 I/O 错误。

read

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

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

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

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

write

public void write(int b)
           throws IOException
从接口 DataOutput 复制的描述
将参数 b 的八个低位写入输出流。忽略 b 的 24 个高位。

指定者:
接口 DataOutput 中的 write
指定者:
接口 ImageOutputStream 中的 write
指定者:
ImageOutputStreamImpl 中的 write
参数:
b - 要写入的字节。
抛出:
IOException - 如果发生 I/O 错误。

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
从接口 DataOutput 复制的描述
将数组 b 中的 len 个字节按顺序写入输出流。如果 bnull,则抛出 NullPointerException。如果 off 为负,或 len 为负,抑或 off+len 大于数组 b 的长度,则抛出 IndexOutOfBoundsException。如果 len 为零,则不写入字节。否则,首先写入字节 b[off],然后写入字节 b[off+1],依此类推;最后一个写入字节是 b[off+len-1]

指定者:
接口 DataOutput 中的 write
指定者:
接口 ImageOutputStream 中的 write
指定者:
ImageOutputStreamImpl 中的 write
参数:
b - 数据。
off - 数据中的起始偏移量。
len - 要写入的字节数。
抛出:
IOException - 如果发生 I/O 错误。

length

public long length()
从类 ImageInputStreamImpl 复制的描述
返回 -1L,指示流的长度未知。子类必须重写此方法来提供实际的长度信息。

指定者:
接口 ImageInputStream 中的 length
覆盖:
ImageInputStreamImpl 中的 length
返回:
指示不知道长度的 -1L。

seek

public void seek(long pos)
          throws IOException
设置当前流位置并将位偏移量重置为 0。查找文件末尾的后面是合法的;仅当在该处执行读取时才抛出 EOFException。在执行写入前,文件长度不会增加。

指定者:
接口 ImageInputStream 中的 seek
覆盖:
ImageInputStreamImpl 中的 seek
参数:
pos - 一个 long,它包含所需文件的指针位置。
抛出:
IndexOutOfBoundsException - 如果 pos 小于刷新的位置。
IOException - 如果发生任何其他 I/O 错误。

isCached

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

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