Binary(Little-endian) file reading problem in applet
Hi,
I'm reading a STL binary file using the following code:
public void LoadSTLBinary(DataInputStream datainputstream) throws Exception {
datainputstream.read(new byte[80]);
int iTriaCount = readInt(datainputstream);
System.out.println("Tiangles_bitwise : " + iTriaCount);
triangles = new Triangle[iTriaCount];
......
......
datainputstream.close();
}
//Needed since binary file is in little endian format
public int readInt(DataInputStream datainputstream) throws IOException {
int i = datainputstream.readInt();
return ((i & 0xff) << 24) + ((i & 0xff00) << 8) + ((i & 0xff0000) >> 8) + (i >> 24 & 0xff);
}
Note: attached Sample STL binary file. (not a ms word file)
When i run the code as a java application, the system.out.println outputs - "Tiangles_bitwise : 4"
but when called in a applet , the system.out.println outputs - "Tiangles_bitwise : 1146060800"
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.