mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 09:02:34 -06:00
81 lines
2.1 KiB
Java
81 lines
2.1 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;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
class MultiReader extends Reader {
|
|
|
|
@CheckForNull
|
|
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 {
|
|
Preconditions.checkNotNull(cArr);
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|