Package java.nio

Class ByteOrder

java.lang.Object
java.nio.ByteOrder

public final class ByteOrder
extends Object
Defines byte order constants.
  • Field Details

    • BIG_ENDIAN

      public static final ByteOrder BIG_ENDIAN
      This constant represents big endian.
    • LITTLE_ENDIAN

      public static final ByteOrder LITTLE_ENDIAN
      This constant represents little endian.
    • needsSwap

      public final boolean needsSwap
      This is the only thing that ByteOrder is really used for: to know whether we need to swap bytes to get this order, given bytes in native order. (That is, this is the opposite of the hypothetical "isNativeOrder".)
  • Method Details

    • nativeOrder

      public static ByteOrder nativeOrder()
      Returns the current platform byte order.
      Returns:
      the byte order object, which is either LITTLE_ENDIAN or BIG_ENDIAN.
    • toString

      public String toString()
      Returns a string that describes this object.
      Overrides:
      toString in class Object
      Returns:
      "BIG_ENDIAN" for ByteOrder.BIG_ENDIAN objects, "LITTLE_ENDIAN" for ByteOrder.LITTLE_ENDIAN objects.