public class FileCacheImageOutputStream extends ImageOutputStreamImpl
ImageOutputStream ,将其输出写入常规的OutputStream 。 
       一个文件用于缓存数据,直到它被刷新到输出流。 
      bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description | 
|---|
| FileCacheImageOutputStream(OutputStream stream, File cacheDir)
              构造一个 
              FileCacheImageOutputStream,它将写入给定的outputStream。 | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()
              关闭此 
              FileCacheImageOutputStream。 | 
| void | flushBefore(long pos)
              在指示的位置之前丢弃流的初始部分。 
             | 
| boolean | isCached()
              返回 
              true因为这ImageOutputStream缓存数据以允许向后搜索。 | 
| boolean | isCachedFile()
              返回 
              true因为这个ImageOutputStream维护一个文件缓存。 | 
| boolean | isCachedMemory()
              返回 
              false因为这ImageOutputStream不维护主内存缓存。 | 
| long | length()
              返回 
              -1L以表示该流具有未知长度。 | 
| int | read()
              从流中读取一个字节,并将其作为0和255之间的 
              int返回。 | 
| 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)
              将当前位置的单个字节写入流。 
             | 
flushBits, write, writeBit, writeBits, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongs, writeShort, writeShorts, writeUTFcheckClosed, 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, skipBytesclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflush, 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, skipBytespublic FileCacheImageOutputStream(OutputStream stream, File cacheDir) throws IOException
FileCacheImageOutputStream ,它将写入给定的outputStream 。 
            临时文件用作缓存。 如果cacheDir是非null并且是一个目录,那么该文件将在那里创建。 如果是null ,将使用系统相关的默认临时文件目录(有关详细信息,请参阅File.createTempFile的File.createTempFile )。 
stream - 
            OutputStream 。 
           cacheDir - 一个 
            File指示应该创建缓存文件的位置,或者使用 
            null来使用系统目录。 
           IllegalArgumentException - 如果 
            stream是 
            null 。 
           IllegalArgumentException - 如果 
            cacheDir不是 
            null但不是目录。 
           IOException - 如果无法创建缓存文件。 
           public int read()
         throws IOException 
          ImageInputStreamImpl 
          int 255之间0和如果达到EOF, -1被返回。 
           子类必须为此方法提供一个实现。 子类实现应该在退出之前更新流位置。
在发生读取之前,流内的位偏移必须重置为零。
read在接口 
            ImageInputStream 
           read在 
            ImageInputStreamImpl 
           -1 。 
           IOException - 如果流已关闭。 
           public int read(byte[] b,
                int off,
                int len)
         throws IOException 
          ImageInputStreamImpl 
          len从流字节,并将其存储到b开始于索引off 。 
           如果没有字节可以读取,因为已经到达流的末尾,则返回-1 。 
           在发生读取之前,流内的位偏移必须重置为零。
子类必须为此方法提供一个实现。 子类实现应该在退出之前更新流位置。
read在接口 
            ImageInputStream 
           read在 
            ImageInputStreamImpl类 
           b - 要写入的字节数组。 
           off - 
            b内写入的起始位置。 
           len - 要读取的最大字节数。 
           -1表示EOF。 
           IOException - 如果发生I / O错误。 
           public void write(int b)
           throws IOException 
          ImageOutputStream复制 
          b的24位b被忽略。 
            如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。 
write在接口 
            DataOutput 
           write在接口 
            ImageOutputStream 
           write在 
            ImageOutputStreamImpl 
           b - 要写入低8位的 
            int 。 
           IOException - 如果发生I / O错误。 
           public void write(byte[] b,
                  int off,
                  int len)
           throws IOException 
          ImageOutputStream复制 
          len为0,则不写任何内容。 
           字节b[off]先写,然后字节b[off + 1]等等。 
            如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。 
write在接口 
            DataOutput 
           write在接口 
            ImageOutputStream 
           write在 
            ImageOutputStreamImpl 
           b - 要编写的 
            byte的数组。 
           off - 数据中的起始偏移量。 
           len -数量 
            byte s到写。 
           IOException - 如果发生I / O错误。 
           public long length()
ImageInputStreamImpl 
          -1L以表示该流具有未知长度。 
           子类必须覆盖此方法以提供实际的长度信息。 
          length在接口 
            ImageInputStream 
           length在 
            ImageInputStreamImpl类 
           public void seek(long pos)
          throws IOException 
          EOFException会,如果执行读取只抛出。 
           在执行写入之前,文件长度不会增加。 
          seek在接口 
            ImageInputStream 
           seek在 
            ImageInputStreamImpl 
           pos - 一个 
            long所需文件指针位置的long。 
           IndexOutOfBoundsException - 如果 
            pos小于冲洗位置。 
           IOException - 如果发生任何其他I / O错误。 
           public boolean isCached()
true因为这 
           ImageOutputStream缓存数据,以便向后追溯。 
          isCached在接口 
            ImageInputStream 
           isCached在 
            ImageInputStreamImpl 
           true 。 
           isCachedMemory() , 
            isCachedFile() 
           public boolean isCachedFile()
true因为这 
           ImageOutputStream维护一个文件缓存。 
          isCachedFile在接口 
            ImageInputStream 
           isCachedFile在 
            ImageInputStreamImpl 
           true 。 
           isCached() , 
            isCachedMemory() 
           public boolean isCachedMemory()
false因为此 
           ImageOutputStream不维护主内存缓存。 
          isCachedMemory中的 
            ImageInputStream 
           isCachedMemory在 
            ImageInputStreamImpl 
           false 。 
           isCached() , 
            isCachedFile() 
           public void close()
           throws IOException 
          FileCacheImageOutputStream 。 
           所有挂起的数据都被刷新到输出,缓存文件被关闭并被删除。 
           目的地OutputStream未关闭。 
          close在接口 
            Closeable 
           close在接口 
            AutoCloseable 
           close在接口 
            ImageInputStream 
           close在 
            ImageInputStreamImpl 
           IOException - 如果发生错误。 
           public void flushBefore(long pos)
                 throws IOException 
          ImageInputStream 
          IndexOutOfBoundsException 。 
            调用flushBefore可能允许实现此接口的类释放用于存储流中的数据的资源(如内存或磁盘空间)。 
flushBefore在接口 
            ImageInputStream 
           flushBefore中的 
            ImageOutputStream 
           flushBefore在 
            ImageInputStreamImpl 
           pos - 一个 
            long其中包含可能被刷新的流前缀的长度。 
           IOException - 如果发生I / O错误。 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.