Methods Summary |
---|
public int | available()Returns the number of bytes available without blocking. It (currently)
always returns {@code 0} in Android.
return 0;
|
public void | close()Closes this {@code CipherInputStream}, also closes the underlying input
stream and call {@code doFinal} on the cipher object.
in.close();
try {
cipher.doFinal();
} catch (GeneralSecurityException ignore) {
//do like RI does
}
|
public boolean | markSupported()Returns whether this input stream supports {@code mark} and {@code reset}
, which it does not.
return false;
|
public int | read()Reads the next byte from this cipher input stream.
if (finished) {
return ((o_buffer == null) || (index == o_buffer.length))
? -1
: o_buffer[index++] & 0xFF;
}
if ((o_buffer != null) && (index < o_buffer.length)) {
return o_buffer[index++] & 0xFF;
}
index = 0;
o_buffer = null;
int num_read;
while (o_buffer == null) {
if ((num_read = in.read(i_buffer)) == -1) {
try {
o_buffer = cipher.doFinal();
} catch (Exception e) {
throw new IOException(e.getMessage());
}
finished = true;
break;
}
o_buffer = cipher.update(i_buffer, 0, num_read);
}
return read();
|
public int | read(byte[] b)Reads the next {@code b.length} bytes from this input stream into buffer
{@code b}.
return read(b, 0, b.length);
|
public int | read(byte[] b, int off, int len)Reads the next {@code len} bytes from this input stream into buffer
{@code b} starting at offset {@code off}.
if {@code b} is {@code null}, the next {@code len} bytes are read and
discarded.
if (in == null) {
throw new NullPointerException("Underlying input stream is null");
}
int read_b;
int i;
for (i=0; i<len; i++) {
if ((read_b = read()) == -1) {
return (i == 0) ? -1 : i;
}
if (b != null) {
b[off+i] = (byte) read_b;
}
}
return i;
|
public long | skip(long n)Skips up to n bytes from this input stream.
The number of bytes skipped depends on the result of a call to
{@link CipherInputStream#available() available}. The smaller of n and the
result are the number of bytes being skipped.
Skipping is (currently) not supported in Android.
long i = 0;
int available = available();
if (available < n) {
n = available;
}
while ((i < n) && (read() != -1)) {
i++;
}
return i;
|