01: package org.bouncycastle.sasn1;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.IOException;
05: import java.io.InputStream;
06:
07: abstract class LimitedInputStream extends InputStream {
08: protected final InputStream _in;
09:
10: LimitedInputStream(InputStream in) {
11: this ._in = in;
12: }
13:
14: byte[] toByteArray() throws IOException {
15: ByteArrayOutputStream bOut = new ByteArrayOutputStream();
16:
17: int b = 0;
18: while ((b = this .read()) >= 0) {
19: bOut.write(b);
20: }
21:
22: return bOut.toByteArray();
23: }
24:
25: InputStream getUnderlyingStream() {
26: return _in;
27: }
28:
29: protected void setParentEofDetect(boolean on) {
30: if (_in instanceof IndefiniteLengthInputStream) {
31: ((IndefiniteLengthInputStream) _in).setEofOn00(on);
32: }
33: }
34: }
|