35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
|
package java.nio; |
|
38 |
|
|
39 |
|
package java.nio; |
40 |
|
|
41 |
|
/** |
42 |
|
* @author Michael Koch |
43 |
|
* @since 1.4 |
44 |
|
*/ |
45 |
public final class ByteOrder |
public final class ByteOrder |
46 |
{ |
{ |
47 |
public static final ByteOrder BIG_ENDIAN = new ByteOrder(); |
public static final ByteOrder BIG_ENDIAN = new ByteOrder(); |
48 |
public static final ByteOrder LITTLE_ENDIAN = new ByteOrder(); |
public static final ByteOrder LITTLE_ENDIAN = new ByteOrder(); |
49 |
|
|
50 |
public static ByteOrder nativeOrder() |
/** |
51 |
|
* Returns the native byte order of the platform currently running. |
52 |
|
*/ |
53 |
|
public static ByteOrder nativeOrder () |
54 |
{ |
{ |
55 |
return BIG_ENDIAN; |
return (System.getProperty ("gnu.cpu.endian") == "big" |
56 |
|
? BIG_ENDIAN : LITTLE_ENDIAN); |
57 |
} |
} |
58 |
|
|
59 |
|
/** |
60 |
|
* Returns a string representation of the byte order. |
61 |
|
*/ |
62 |
public String toString() |
public String toString() |
63 |
{ |
{ |
64 |
return this == BIG_ENDIAN ? "BIG_ENDIAN" : "LITTLE_ENDIAN"; |
return this == BIG_ENDIAN ? "BIG_ENDIAN" : "LITTLE_ENDIAN"; |