Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7808393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:07:23+00:00 2026-06-02T03:07:23+00:00

I have a java.nio.MappedByteBuffer that I am using to read integers from a little-endian

  • 0

I have a java.nio.MappedByteBuffer that I am using to read integers from a little-endian file. I set the byte order to LITTLE_ENDIAN using ByteBuffer.order(), but this causes the buffer to interpret integers as if they were big endian.

Confirm that we have the number 3 in little endian in bytes 4-7

>> sprintf( '%.2x ', qfunction.s_idx.get(4), qfunction.s_idx.get(5), qfunction.s_idx.get(6), qfunction.s_idx.get(7) )

ans =

03 00 00 00 

Reading as LITTLE_ENDIAN returns 0x03000000 instead of 0x00000003!

>> qfunction.s_idx.order( java.nio.ByteOrder.LITTLE_ENDIAN );
>> sprintf( '%.8x', qfunction.s_idx.getInt(1) )

ans =

03000000

Reading as BIG_ENDIAN does return 3!*

>> qfunction.s_idx.order( java.nio.ByteOrder.BIG_ENDIAN );
>> sprintf( '%.8x', qfunction.s_idx.getInt(1) )

ans =

00000003

What is going on here?

Using Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
Using MATLAB R2011b

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:07:24+00:00Added an answer on June 2, 2026 at 3:07 am

    You are writing bytes 4,5,6,7 but reading bytes 1,2,3,4. This makes byte 4 (which is the only one with a value) appear at the end instead of the start,

    Try instead

    >> sprintf( '%.8x', qfunction.s_idx.getInt(4) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a server that performs non-blocking IO using the Java NIO API.
I have a Java client that connects to a C++ server using TCP Sockets
I'm programming a simple Java NIO server and have a little headache: I get
I have a process that will be called rather frequently from cron to read
I have a java code for copy file from one folder to another folder.
I have java script code to set some of the properties of ajax controls.
I have Java Map (out of Strings and Ints) objects that I want to
I have java source code in a text file. There has to be entered
I already have Java code to display and process data from a database. I
In my source tree have Java code which is automatically generated from XSD files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.