what-the-bank/sources/com/google/common/io/LittleEndianDataInputStream...

114 lines
3.8 KiB
Java

package com.google.common.io;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes2.dex */
public final class LittleEndianDataInputStream extends FilterInputStream implements DataInput {
public LittleEndianDataInputStream(InputStream inputStream) {
super((InputStream) Preconditions.checkNotNull(inputStream));
}
@Override // java.io.DataInput
public final String readLine() {
throw new UnsupportedOperationException("readLine is not supported");
}
@Override // java.io.DataInput
public final void readFully(byte[] bArr) throws IOException {
ByteStreams.readFully(this, bArr);
}
@Override // java.io.DataInput
public final void readFully(byte[] bArr, int i, int i2) throws IOException {
ByteStreams.readFully(this, bArr, i, i2);
}
@Override // java.io.DataInput
public final int skipBytes(int i) throws IOException {
return (int) ((FilterInputStream) this).in.skip(i);
}
@Override // java.io.DataInput
public final int readUnsignedByte() throws IOException {
int read = ((FilterInputStream) this).in.read();
if (read >= 0) {
return read;
}
throw new EOFException();
}
@Override // java.io.DataInput
public final int readUnsignedShort() throws IOException {
return Ints.fromBytes((byte) 0, (byte) 0, readAndCheckByte(), readAndCheckByte());
}
@Override // java.io.DataInput
public final int readInt() throws IOException {
byte readAndCheckByte = readAndCheckByte();
byte readAndCheckByte2 = readAndCheckByte();
return Ints.fromBytes(readAndCheckByte(), readAndCheckByte(), readAndCheckByte2, readAndCheckByte);
}
@Override // java.io.DataInput
public final long readLong() throws IOException {
byte readAndCheckByte = readAndCheckByte();
byte readAndCheckByte2 = readAndCheckByte();
byte readAndCheckByte3 = readAndCheckByte();
byte readAndCheckByte4 = readAndCheckByte();
byte readAndCheckByte5 = readAndCheckByte();
byte readAndCheckByte6 = readAndCheckByte();
return Longs.fromBytes(readAndCheckByte(), readAndCheckByte(), readAndCheckByte6, readAndCheckByte5, readAndCheckByte4, readAndCheckByte3, readAndCheckByte2, readAndCheckByte);
}
@Override // java.io.DataInput
public final float readFloat() throws IOException {
return Float.intBitsToFloat(readInt());
}
@Override // java.io.DataInput
public final double readDouble() throws IOException {
return Double.longBitsToDouble(readLong());
}
@Override // java.io.DataInput
public final String readUTF() throws IOException {
return new DataInputStream(((FilterInputStream) this).in).readUTF();
}
@Override // java.io.DataInput
public final short readShort() throws IOException {
return (short) readUnsignedShort();
}
@Override // java.io.DataInput
public final char readChar() throws IOException {
return (char) readUnsignedShort();
}
@Override // java.io.DataInput
public final byte readByte() throws IOException {
return (byte) readUnsignedByte();
}
@Override // java.io.DataInput
public final boolean readBoolean() throws IOException {
return readUnsignedByte() != 0;
}
private byte readAndCheckByte() throws IOException, EOFException {
int read = ((FilterInputStream) this).in.read();
if (-1 != read) {
return (byte) read;
}
throw new EOFException();
}
}