3 Replies Latest reply: Jan 14, 2010 2:27 PM by 807580 RSS

    Java Unicode's Byte Ordering

    807580
      Is there any fixed byte ordering (big vs little endian) used by the Jvm? Or is it just depending on the machine running the Jvm?
        • 1. Re: Java Unicode's Byte Ordering
          EJP
          (a) Unicode byte ordering is a non-existent concept
          (b) DataInputStream and DataOutputStream are big-endian.
          (c) ByteBuffer and friends can be set to different byte orders
          (d) There is no other means of access to byte-ordering in Java AFAIK so the question is actually meaningless. Obviously JVMs would use the native byte ordering in practice but there is no way to tell from inside Java so it doesn't matter.
          • 2. Re: Java Unicode's Byte Ordering
            796440
            In terms of the Java language and the JVM spec, all of Java's types are big-endian. However, as ejp points out, the JVM will use the native byte ordering where required or expedient when interacting with the underlying architecture.
            • 3. Re: Java Unicode's Byte Ordering
              807580
              The point of using a virtual machine is to abstract away annoying details which add little value to developers. byte-ordering of memory is one of these things the JVM abstracts away. Only network and file byte ordering matters and @ejp has covered that.