121 lines
4.0 KiB
Java
121 lines
4.0 KiB
Java
package com.bumptech.glide.disklrucache;
|
|
|
|
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.Closeable;
|
|
import java.io.EOFException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.nio.charset.Charset;
|
|
|
|
/* loaded from: classes.dex */
|
|
class StrictLineReader implements Closeable {
|
|
private final InputStream a;
|
|
private final Charset b;
|
|
private byte[] c;
|
|
private int d;
|
|
private int e;
|
|
|
|
public StrictLineReader(InputStream inputStream, Charset charset) {
|
|
this(inputStream, UnityActivity.BLOCKLY_TYPE_NONE, charset);
|
|
}
|
|
|
|
private void c() throws IOException {
|
|
InputStream inputStream = this.a;
|
|
byte[] bArr = this.c;
|
|
int read = inputStream.read(bArr, 0, bArr.length);
|
|
if (read == -1) {
|
|
throw new EOFException();
|
|
}
|
|
this.d = 0;
|
|
this.e = read;
|
|
}
|
|
|
|
public String b() throws IOException {
|
|
int i;
|
|
int i2;
|
|
synchronized (this.a) {
|
|
if (this.c == null) {
|
|
throw new IOException("LineReader is closed");
|
|
}
|
|
if (this.d >= this.e) {
|
|
c();
|
|
}
|
|
for (int i3 = this.d; i3 != this.e; i3++) {
|
|
if (this.c[i3] == 10) {
|
|
if (i3 != this.d) {
|
|
i2 = i3 - 1;
|
|
if (this.c[i2] == 13) {
|
|
String str = new String(this.c, this.d, i2 - this.d, this.b.name());
|
|
this.d = i3 + 1;
|
|
return str;
|
|
}
|
|
}
|
|
i2 = i3;
|
|
String str2 = new String(this.c, this.d, i2 - this.d, this.b.name());
|
|
this.d = i3 + 1;
|
|
return str2;
|
|
}
|
|
}
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream((this.e - this.d) + 80) { // from class: com.bumptech.glide.disklrucache.StrictLineReader.1
|
|
@Override // java.io.ByteArrayOutputStream
|
|
public String toString() {
|
|
int i4 = ((ByteArrayOutputStream) this).count;
|
|
try {
|
|
return new String(((ByteArrayOutputStream) this).buf, 0, (i4 <= 0 || ((ByteArrayOutputStream) this).buf[i4 + (-1)] != 13) ? ((ByteArrayOutputStream) this).count : i4 - 1, StrictLineReader.this.b.name());
|
|
} catch (UnsupportedEncodingException e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
};
|
|
loop1: while (true) {
|
|
byteArrayOutputStream.write(this.c, this.d, this.e - this.d);
|
|
this.e = -1;
|
|
c();
|
|
i = this.d;
|
|
while (i != this.e) {
|
|
if (this.c[i] == 10) {
|
|
break loop1;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
if (i != this.d) {
|
|
byteArrayOutputStream.write(this.c, this.d, i - this.d);
|
|
}
|
|
this.d = i + 1;
|
|
return byteArrayOutputStream.toString();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
synchronized (this.a) {
|
|
if (this.c != null) {
|
|
this.c = null;
|
|
this.a.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
public StrictLineReader(InputStream inputStream, int i, Charset charset) {
|
|
if (inputStream == null || charset == null) {
|
|
throw new NullPointerException();
|
|
}
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException("capacity <= 0");
|
|
}
|
|
if (!charset.equals(Util.a)) {
|
|
throw new IllegalArgumentException("Unsupported encoding");
|
|
}
|
|
this.a = inputStream;
|
|
this.b = charset;
|
|
this.c = new byte[i];
|
|
}
|
|
|
|
public boolean a() {
|
|
return this.e == -1;
|
|
}
|
|
}
|