how to get endianess in Java or python?

后端 未结 4 1155
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 05:08

In C I could the Endianess of the machine by the following method. how would I get using a python or Java program?. In Ja

4条回答
  •  生来不讨喜
    2021-01-14 05:32

    import java.nio.ByteOrder;
    
    public class Endian {
        public static void main(String argv[]) {
            ByteOrder b = ByteOrder.nativeOrder();
            if (b.equals(ByteOrder.BIG_ENDIAN)) {
                System.out.println("Big-endian");
            } else {
            System.out.println("Little-endian");
            }
        }
    }
    

    valter

提交回复
热议问题