77 lines
2.0 KiB
Java
77 lines
2.0 KiB
Java
|
package com.google.common.io;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import java.io.IOException;
|
||
|
import java.io.Reader;
|
||
|
import java.util.Iterator;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
class MultiReader extends Reader {
|
||
|
private Reader current;
|
||
|
private final Iterator<? extends CharSource> it;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public MultiReader(Iterator<? extends CharSource> it) throws IOException {
|
||
|
this.it = it;
|
||
|
advance();
|
||
|
}
|
||
|
|
||
|
private void advance() throws IOException {
|
||
|
close();
|
||
|
if (this.it.hasNext()) {
|
||
|
this.current = this.it.next().openStream();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Reader
|
||
|
public int read(char[] cArr, int i, int i2) throws IOException {
|
||
|
Reader reader = this.current;
|
||
|
if (reader == null) {
|
||
|
return -1;
|
||
|
}
|
||
|
int read = reader.read(cArr, i, i2);
|
||
|
if (read != -1) {
|
||
|
return read;
|
||
|
}
|
||
|
advance();
|
||
|
return read(cArr, i, i2);
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Reader
|
||
|
public long skip(long j) throws IOException {
|
||
|
Preconditions.checkArgument(j >= 0, "n is negative");
|
||
|
if (j > 0) {
|
||
|
while (true) {
|
||
|
Reader reader = this.current;
|
||
|
if (reader == null) {
|
||
|
break;
|
||
|
}
|
||
|
long skip = reader.skip(j);
|
||
|
if (skip > 0) {
|
||
|
return skip;
|
||
|
}
|
||
|
advance();
|
||
|
}
|
||
|
}
|
||
|
return 0L;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Reader
|
||
|
public boolean ready() throws IOException {
|
||
|
Reader reader = this.current;
|
||
|
return reader != null && reader.ready();
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public void close() throws IOException {
|
||
|
Reader reader = this.current;
|
||
|
if (reader != null) {
|
||
|
try {
|
||
|
reader.close();
|
||
|
} finally {
|
||
|
this.current = null;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|