JavaTM 2 Platform
Standard Ed. 6

javax.imageio.stream
类 FileImageInputStream

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

public class FileImageInputStream
extends ImageInputStreamImpl

FileRandomAccessFile 中获取输入的 ImageInputStream 的实现。假定文件内容在对象的生存期内是稳定的。


字段摘要
 
从类 javax.imageio.stream.ImageInputStreamImpl 继承的字段
bitOffset, byteOrder, flushedPos, streamPos
 
构造方法摘要
FileImageInputStream(File f)
          构造一个将从给定 File 进行读取的 FileImageInputStream
FileImageInputStream(RandomAccessFile raf)
          构造一个将从给定 RandomAccessFile 进行读取的 FileImageInputStream
 
方法摘要
 void close()
          关闭流。
protected  void finalize()
          在垃圾回收前结束此对象。
 long length()
          返回底层文件的长度,如果其为未知,则返回 -1
 int read()
          从流中读取单个字节,并以 int(0 到 255 之间)形式返回该字节。
 int read(byte[] b, int off, int len)
          从流中读取至多 len 个字节,并将其存储到 b 中(从 off 索引处开始)。
 void seek(long pos)
          将当前流位置设置为所需的位置。
 
从类 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
 

构造方法详细信息

FileImageInputStream

public FileImageInputStream(File f)
                     throws FileNotFoundException,
                            IOException
构造一个将从给定 File 进行读取的 FileImageInputStream

在构造此对象和最后一次调用 read 方法之间的时间内,一定不能更改文件内容。

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

FileImageInputStream

public FileImageInputStream(RandomAccessFile raf)
构造一个将从给定 RandomAccessFile 进行读取的 FileImageInputStream

在构造此对象和最后一次调用 read 方法之间的时间内,一定不能更改文件内容。

参数:
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 错误。

length

public long length()
返回底层文件的长度,如果其为未知,则返回 -1

指定者:
接口 ImageInputStream 中的 length
覆盖:
ImageInputStreamImpl 中的 length
返回:
long 形式返回文件的长度,或者返回 -1

seek

public void seek(long pos)
          throws IOException
从接口 ImageInputStream 复制的描述
将当前流位置设置为所需的位置。下一次读取将在此位置上进行。位偏移量被设置为 0。

如果 pos 小于刷新位置(由 getflushedPosition 返回),那么将抛出 IndexOutOfBoundsException

查找文件结束标记的后面是合法的,只有在该处执行读取时才抛出 EOFException

指定者:
接口 ImageInputStream 中的 seek
覆盖:
ImageInputStreamImpl 中的 seek
参数:
pos - 一个 long,它包含所需的文件指针位置。
抛出:
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 2 Platform
Standard Ed. 6

提交错误或意见

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