ChainedInputStream.java
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.internal.io;
import java.io.IOException;
import java.io.InputStream;
public class ChainedInputStream
extends InputStream {
private InputStream[] streams;
private int streamIndex;
private int streamCount;
private static final int EOF = -1;
public ChainedInputStream(InputStream[] streams) {
this.streams = streams;
this.streamCount = streams.length;
}
@Override
public int read() throws IOException {
if (this.streamIndex >= this.streamCount) {
return -1;
}
int value = this.streams[this.streamIndex].read();
while (value == -1 && ++this.streamIndex < this.streamCount) {
value = this.streams[this.streamIndex].read();
}
return value;
}
@Override
public int available() throws IOException {
if (this.streamIndex >= this.streamCount) {
return 0;
}
return this.streams[this.streamIndex].available();
}
@Override
public void close() throws IOException {
for (int i = 0; i < this.streamCount; ++i) {
this.streams[i].close();
}
this.streams = null;
this.streamCount = 0;
}
}