mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-06 12:29:32 +01:00
104 lines
2.9 KiB
Java
104 lines
2.9 KiB
Java
package com.google.common.io;
|
|
|
|
import com.google.common.annotations.GwtIncompatible;
|
|
import com.google.common.annotations.J2ktIncompatible;
|
|
import com.google.common.base.Preconditions;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.Iterator;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
/* loaded from: classes8.dex */
|
|
final class MultiInputStream extends InputStream {
|
|
private InputStream in;
|
|
|
|
/* renamed from: it, reason: collision with root package name */
|
|
private Iterator<? extends ByteSource> f1138it;
|
|
|
|
public MultiInputStream(Iterator<? extends ByteSource> it2) throws IOException {
|
|
this.f1138it = (Iterator) Preconditions.checkNotNull(it2);
|
|
advance();
|
|
}
|
|
|
|
private void advance() throws IOException {
|
|
close();
|
|
if (this.f1138it.hasNext()) {
|
|
this.in = this.f1138it.next().openStream();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int available() throws IOException {
|
|
InputStream inputStream = this.in;
|
|
if (inputStream == null) {
|
|
return 0;
|
|
}
|
|
return inputStream.available();
|
|
}
|
|
|
|
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
InputStream inputStream = this.in;
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} finally {
|
|
this.in = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public boolean markSupported() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read(byte[] bArr, int i, int i2) throws IOException {
|
|
Preconditions.checkNotNull(bArr);
|
|
while (true) {
|
|
InputStream inputStream = this.in;
|
|
if (inputStream == null) {
|
|
return -1;
|
|
}
|
|
int read = inputStream.read(bArr, i, i2);
|
|
if (read != -1) {
|
|
return read;
|
|
}
|
|
advance();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public long skip(long j) throws IOException {
|
|
InputStream inputStream = this.in;
|
|
if (inputStream == null || j <= 0) {
|
|
return 0L;
|
|
}
|
|
long skip = inputStream.skip(j);
|
|
if (skip != 0) {
|
|
return skip;
|
|
}
|
|
if (read() == -1) {
|
|
return 0L;
|
|
}
|
|
return this.in.skip(j - 1) + 1;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read() throws IOException {
|
|
while (true) {
|
|
InputStream inputStream = this.in;
|
|
if (inputStream == null) {
|
|
return -1;
|
|
}
|
|
int read = inputStream.read();
|
|
if (read != -1) {
|
|
return read;
|
|
}
|
|
advance();
|
|
}
|
|
}
|
|
}
|