ExtendedDataInputStream.java 1.36 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.internal.io;

import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

public class ExtendedDataInputStream
extends DataInputStream {
    public ExtendedDataInputStream(InputStream in) {
        super(in);
    }

    public long readUnsignedInt() throws IOException {
        long value = 0;
        for (int i = 0; i < 4; ++i) {
            int b = this.read();
            if (b == -1) {
                throw new EOFException("Unexpected end of stream.");
            }
            value = (value << 8) + (long)(b & 255);
        }
        return value;
    }

    public int readUnsigned3ByteInt() throws IOException {
        int value = 0;
        for (int i = 0; i < 3; ++i) {
            int b = this.read();
            if (b == -1) {
                throw new EOFException("Unexpected end of stream.");
            }
            value = (value << 8) + (b & 255);
        }
        return value;
    }

    public void skipFully(long n) throws IOException {
        long totalBytesSkipped = 0;
        while (n > 0) {
            long bytesSkipped = super.skip(n);
            if (bytesSkipped == 0) {
                throw new EOFException("Unable to skip.");
            }
            n -= bytesSkipped;
            totalBytesSkipped += bytesSkipped;
        }
    }
}