They're little-endian ushorts so
// http://darksleep.com/player/JavaAndUnsignedTypes.html
static char ReadUShort(InputStream iS, int offset)
{
byte[] bucket = ReadBytes(iS, offset, 2);
// switched bytes for little-endian:
int firstByte = (0x000000FF & ((int)bucket[1]));
int secondByte = (0x000000FF & ((int)bucket[0]));
return (char) (firstByte << 8 | secondByte);
}
static byte[] ReadBytes(InputStream iS, int offset, int readlen)
{
byte[] bucket = new byte[offset+readlen];
try
{
iS.read(bucket, offset, readlen);
}
catch (IOException e)
{
e.printStackTrace();
}
byte subbucket[] = new byte[readlen];
for(int i=0; i<readlen; i++)
subbucket = bucket[offset+i];
return subbucket;
}