Java 中的 ShortBuffer order() 方法
可以使用 java.nio.ShortBuffer 类中 order() 方法获取缓冲区的字节顺序。此方法不需要参数,它返回缓冲区的字节顺序。
演示此方法的程序如下 −
示例
import java.nio.*;
import java.util.*;
public class Demo {
public static void main(String[] args) {
int n = 5;
try {
ShortBuffer buffer = ShortBuffer.allocate(n);
buffer.put((short)12);
buffer.put((short)91);
buffer.put((short)25);
buffer.put((short)18);
buffer.put((short)30);
System.out.println("The byte order of the buffer is: " + buffer.order());
} catch (IllegalArgumentException e) {
System.out.println("Error!!! IllegalArgumentException");
} catch (ReadOnlyBufferException e) {
System.out.println("Error!!! ReadOnlyBufferException");
}
}
}以上程序的输出如下 −
输出
The byte order of the buffer is: LITTLE_ENDIAN
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP