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和密码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 -初始化密码对象
protected CipherInputStream(InputStream is)
is -待处理的输入流
public int read()
throws IOException
0一
int到
255返回。如果没有可用的字节,因为已到达流的末尾,则返回值
-1。此方法块,直到输入数据可用,流的结束被检测到,或抛出异常。
read 方法重写,继承类
FilterInputStream
-1如果到达流的末尾。
IOException如果I/O错误发生。
FilterInputStream.in
public int read(byte[] b)
throws IOException
b.length字节从输入流到字节数组数据。
对InputStream的read方法调用三参数与参数的方法b,read 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小于零,没有字节被跳过。
跳过的字节数实际返回。
skip 方法重写,继承类
FilterInputStream
n -字节数被跳过。
IOException如果I/O错误发生。
public int available()
throws IOException
InputStream返回
0的
available方法。这种方法
应该是由子类重写。
available 方法重写,继承类
FilterInputStream
IOException如果I/O错误发生。
public void close()
throws IOException
对CipherInputStream的close方法调用其数据输入流的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.