SeptetPackingInputStream.java
package net.morimekta.io;
import java.io.IOException;
import java.io.InputStream;
/**
* An input stream that reads
*/
public class SeptetPackingInputStream extends InputStream {
private BitPackingInputStream in;
public SeptetPackingInputStream(InputStream in) {
this.in = in instanceof BitPackingInputStream
? (BitPackingInputStream) in
: new BitPackingInputStream(in);
}
@Override
public int read() throws IOException {
if (in == null) {
throw new IOException("Reading from closed stream");
}
return in.readBits(7);
}
@Override
public int available() throws IOException {
return in == null ? 0 : in.available(7);
}
@Override
public void close() throws IOException {
if (in != null) {
try {
in.close();
} finally {
in = null;
}
}
}
}