CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Question 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"

    Any help highly appreciated.

    Regards,
    Rajan_M
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured