Use Guava's LittleEndianDataInputStream.

This replaces the custom LittleEndianDataInputStream with
guava's implementation. To do this, I had to fix ExtDataInput
to better handle the case where skipBytes doesn't skip all the
bytes (the tests failed without this, and succeed with it). This
appears to be the main difference between the two implementations.
Guava's implementation is preferred because it is already a
dependency and because its license is clearer (the previous
implementation had a vague "public domain" comment in the thread
which may not be legally sufficient).

Fixes #1166
This commit is contained in:
Anthony Morris
2016-08-05 14:17:19 +01:00
parent 10d09f208c
commit e23eb9cf6b
4 changed files with 27 additions and 143 deletions

View File

@ -76,6 +76,22 @@ public class ExtDataInput extends DataInputDelegate {
}
}
/**
* The general contract of DataInput doesn't guarantee all the bytes requested will be skipped
* and failure can occur for many reasons. We override this to try harder to skip all the bytes
* requested (this is similar to DataInputStream's wrapper).
*/
public final int skipBytes(int n) throws IOException {
int total = 0;
int cur = 0;
while ((total < n) && ((cur = (int) super.skipBytes(n - total)) > 0)) {
total += cur;
}
return total;
}
public String readNullEndedString(int length, boolean fixed)
throws IOException {
StringBuilder string = new StringBuilder(16);