projects
/
svjatoslav_commons.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated copyright
[svjatoslav_commons.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
commons
/
data
/
BitInputStream.java
diff --git
a/src/main/java/eu/svjatoslav/commons/data/BitInputStream.java
b/src/main/java/eu/svjatoslav/commons/data/BitInputStream.java
index
5769eaf
..
f415855
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/data/BitInputStream.java
+++ b/
src/main/java/eu/svjatoslav/commons/data/BitInputStream.java
@@
-1,6
+1,6
@@
/*
* Svjatoslav Commons - shared library of common functionality.
/*
* Svjatoslav Commons - shared library of common functionality.
- * Copyright ©2012-201
4
, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright ©2012-201
9
, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
@@
-9,47
+9,46
@@
package eu.svjatoslav.commons.data;
package eu.svjatoslav.commons.data;
-/**
- * Read individual bits from the input stream.
- */
import java.io.IOException;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
+/**
+ * Read individual bits from the input stream.
+ */
public class BitInputStream {
public class BitInputStream {
- int currentByte;
- int currentBytePointer = -1;
-
- InputStream inputStream;
+ private final InputStream inputStream;
+ private int currentByte;
+ private int currentBytePointer = -1;
-
public BitInputStream(final InputStream inputStream) {
-
this.inputStream = inputStream;
-
}
+ public BitInputStream(final InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
-
public int readBits(final int bitCount) throws IOException {
+ public int readBits(final int bitCount) throws IOException {
-
int readableByte = 0;
-
for (int i = 0; i < bitCount; i++) {
+ int readableByte = 0;
+ for (int i = 0; i < bitCount; i++) {
-
readableByte = readableByte << 1;
+ readableByte = readableByte << 1;
-
if (currentBytePointer == -1) {
-
currentBytePointer = 7;
-
currentByte = inputStream.read();
-
}
+ if (currentBytePointer == -1) {
+ currentBytePointer = 7;
+ currentByte = inputStream.read();
+ }
-
int mask = 1;
-
mask = mask << currentBytePointer;
+ int mask = 1;
+ mask = mask << currentBytePointer;
-
final int currentBit = currentByte & mask;
+ final int currentBit = currentByte & mask;
-
if (currentBit != 0)
-
readableByte = readableByte | 1;
+ if (currentBit != 0)
+ readableByte = readableByte | 1;
-
currentBytePointer--;
-
}
-
return readableByte;
-
}
+ currentBytePointer--;
+ }
+ return readableByte;
+ }
}
}