alexandroid/decompiled/jadx/sources/com/google/common/io/LineReader.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

64 lines
2.2 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 com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
import java.util.ArrayDeque;
import java.util.Queue;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@J2ktIncompatible
@GwtIncompatible
/* loaded from: classes8.dex */
public final class LineReader {
private final char[] buf;
private final CharBuffer cbuf;
private final LineBuffer lineBuf;
private final Queue<String> lines;
private final Readable readable;
private final Reader reader;
public LineReader(Readable readable) {
CharBuffer createBuffer = CharStreams.createBuffer();
this.cbuf = createBuffer;
this.buf = createBuffer.array();
this.lines = new ArrayDeque();
this.lineBuf = new LineBuffer() { // from class: com.google.common.io.LineReader.1
@Override // com.google.common.io.LineBuffer
public void handleLine(String str, String str2) {
LineReader.this.lines.add(str);
}
};
this.readable = (Readable) Preconditions.checkNotNull(readable);
this.reader = readable instanceof Reader ? (Reader) readable : null;
}
@CanIgnoreReturnValue
public String readLine() throws IOException {
int read;
while (true) {
if (this.lines.peek() != null) {
break;
}
Java8Compatibility.clear(this.cbuf);
Reader reader = this.reader;
if (reader != null) {
char[] cArr = this.buf;
read = reader.read(cArr, 0, cArr.length);
} else {
read = this.readable.read(this.cbuf);
}
LineBuffer lineBuffer = this.lineBuf;
if (read == -1) {
lineBuffer.finish();
break;
}
lineBuffer.add(this.buf, 0, read);
}
return this.lines.poll();
}
}