public class CipherInputStream extends FilterInputStream
例如,如果将密码初始化为解密,则CipherInputStream将在返回解密的数据之前尝试读取数据并将其解密。
 该类严格遵守其祖先类java.io.FilterInputStream和java.io.InputStream的语义,特别是失败语义。 这个类只有在其祖先类中指定的方法,并覆盖它们全部。 此外,此类捕获其祖先类不抛出的所有异常。 特别地, skip方法跳过,并且available方法仅计数已由封装的密码处理的数据。 
对于使用此类的程序员,不要使用在此类中未定义或覆盖的方法(例如后来添加到其中一个超类的新方法或构造函数),因为这些方法的设计和实现不太可能考虑到对CipherInputStream的安全性影响。
InputStream , FilterInputStream , Cipher , CipherOutputStream 
       in| Modifier | Constructor and Description | 
|---|---|
| protected  | CipherInputStream(InputStream is)
              从InputStream构造CipherInputStream,而不指定密码。 
             | 
|   | CipherInputStream(InputStream is, Cipher c)
              从InputStream和Cipher构造一个CipherInputStream。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| int | available()
              返回可以从该输入流读取而不阻塞的字节数。 
             | 
| void | close()
              关闭此输入流并释放与流相关联的任何系统资源。 
             | 
| boolean | markSupported()
              测试这个输入流是否支持 
              mark和reset方法,而不是。 | 
| int | read()
              从该输入流读取下一个数据字节。 
             | 
| int | read(byte[] b)
              从该输入流读取最多 
              b.length个字节的数据到字节数组。 | 
| int | read(byte[] b, int off, int len)
              从该输入流读取高达 
              len字节的数据到字节数组。 | 
| long | skip(long n)
              跳过 
              n字节的字节,可从该输入流中读取而不阻塞。 | 
mark, resetpublic CipherInputStream(InputStream is, Cipher c)
is - 要处理的输入流 
           c - 一个初始化的Cipher对象 
           protected CipherInputStream(InputStream is)
is - 待处理的输入流 
           public int read()
         throws IOException 
          int返回,范围为0至255 。 
           如果没有字节可用,因为流已经到达,则返回值-1 。 
           该方法阻塞直到输入数据可用,检测到流的结尾,或抛出异常。 
            
          read在 
            FilterInputStream 
           -1 。 
           IOException - 如果发生I / O错误。 
           FilterInputStream.in 
           public int read(byte[] b)
         throws IOException 
          b.length字节的数据到字节数组。 
            该read的方法InputStream调用read的三个参数与参数方法b , 0和b.length 。 
read在 
            FilterInputStream 
           b - 读取数据的缓冲区。 
           -1是没有更多的数据,因为已经到达流的结尾。 
           IOException - 如果发生I / O错误。 
           InputStream.read(byte[], int, int) 
           public int read(byte[] b,
                int off,
                int len)
         throws IOException 
          len字节的数据到字节数组。 
           此方法将阻塞,直到某些输入可用。 
           如果第一个参数是null,最多可以读取并丢弃len个字节。 
          read在 
            FilterInputStream 
           b - 读取数据的缓冲区。 
           off - 目标数组 
            buf的起始偏移量 
           len - 读取的最大字节数。 
           -1 。 
           IOException - 如果发生I / O错误。 
           InputStream.read() 
           public long skip(long n)
          throws IOException 
          n字节的字节,可从该输入流中读取而不阻塞。 
            可能会跳过比请求的字节少的字节。 跳过的实际字节数等于n或调用available的结果,以较小者为准。 如果n小于0,则不跳过任何字节。 
返回实际跳过的字节数。
skip在 
            FilterInputStream 
           n - 要跳过的字节数。 
           IOException - 如果发生I / O错误。 
           public int available()
              throws IOException 
          available方法InputStream返回0 。 
           这个方法应该被子类覆盖。 
          available在 
            FilterInputStream 
           IOException - 如果发生I / O错误。 
           public void close()
           throws IOException 
           该close的方法CipherInputStream调用close其底层输入流的方法。 
close在界面 
            Closeable 
           close在界面 
            AutoCloseable 
           close在类别 
            FilterInputStream 
           IOException - 如果发生I / O错误。 
           FilterInputStream.in 
           public boolean markSupported()
mark和 
           reset方法,而不是。 
          markSupported在类别 
            FilterInputStream 
           false ,因为这个类不支持 
            mark和 
            reset方法。 
           InputStream.mark(int) , 
            InputStream.reset() 
            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.