JavaTM Platform
Standard Ed. 6

javax.imageio.stream
类 FileImageOutputStream

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

public class FileImageOutputStream
extends ImageOutputStreamImpl

将输出直接写入 FileRandomAccessFileImageOutputStream 的实现。


字段摘要
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的字段
bitOffset, byteOrder, flushedPos, streamPos
 
构造方法摘要
FileImageOutputStream(File f)
          构造一个将向给定 File 进行写入的 FileImageOutputStream
FileImageOutputStream(RandomAccessFile raf)
          构造一个向给定 FileImageOutputStream 进行写入的 RandomAccessFile
 
方法摘要
 void close()
          关闭流。
protected  void finalize()
          在垃圾回收前结束此对象。
 long length()
          返回 -1L,指示流的长度未知。
 int read()
          从流中读取单个字节,并以 int(0 到 255 之间)形式返回该字节。
 int read(byte[] b, int off, int len)
          从流中读取至多 len 个字节,并将其存储到 b 中(从 off 索引处开始)。
 void seek(long pos)
          设置当前流位置并将位偏移量重置为 0。
 void write(byte[] b, int off, int len)
          将字节序列写入到流中的当前位置。
 void write(int 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, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, 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.ImageOutputStream 继承的方法
flushBefore
 
从接口 javax.imageio.stream.ImageInputStream 继承的方法
flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, 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
 

构造方法详细信息

FileImageOutputStream

public FileImageOutputStream(File f)
                      throws FileNotFoundException,
                             IOException
构造一个将向给定 File 进行写入的 FileImageOutputStream

参数:
f - 要写入到的 File
抛出:
IllegalArgumentException - 如果 fnull
SecurityException - 如果存在安全管理器,且不允许对文件进行写入访问。
FileNotFoundException - 如果 f 不指示常规文件,或者由于任何其他原因不能打开以进行读写。
IOException - 如果发生 I/O 错误。

FileImageOutputStream

public FileImageOutputStream(RandomAccessFile raf)
构造一个向给定 FileImageOutputStream 进行写入的 RandomAccessFile

参数:
raf - 要写入到的 RandomAccessFile
抛出:
IllegalArgumentException - 如果 rafnull
方法详细信息

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 错误。

write

public void write(int b)
           throws IOException
从接口 ImageOutputStream 复制的描述
将单个字节写入到流中的当前位置。b 的 24 个高位将被忽略。

如果流中的位偏移量不为零,则首先将当前字节的余项用 0 填充并将其写出。写出后位偏移量将为 0。实现方可使用 ImageOutputStreamImplflushBits 方法来保证这一点。

指定者:
接口 DataOutput 中的 write
指定者:
接口 ImageOutputStream 中的 write
指定者:
ImageOutputStreamImpl 中的 write
参数:
b - 一个 int,其低 8 位将被写入。
抛出:
IOException - 如果发生 I/O 错误。

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
从接口 ImageOutputStream 复制的描述
将字节序列写入到流中的当前位置。如果 len 为 0,则不写入任何字节。首先写入字节 b[off],然后写入字节 b[off + 1],依此类推。

如果流中的位偏移量不为零,则首先将当前字节的余项用 0 填充并将其写出。写出后位偏移量将为 0。实现方可使用 ImageOutputStreamImplflushBits 方法来保证这一点。

指定者:
接口 DataOutput 中的 write
指定者:
接口 ImageOutputStream 中的 write
指定者:
ImageOutputStreamImpl 中的 write
参数:
b - 要写入的 byte 数组。
off - 数据中的初始偏移量。
len - 要写入的 byte 数。
抛出:
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 错误。

close

public void close()
           throws IOException
从接口 ImageInputStream 复制的描述
关闭流。试图访问已经关闭的流将导致 IOException 或错误行为。调用此方法可允许实现此接口的类释放与流关联的资源,如内存、磁盘空间或文件描述符。

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

finalize

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

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

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策