List of usage examples for java.nio ByteBuffer allocate
public static ByteBuffer allocate(int capacity)
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer buf = ByteBuffer.allocate(10); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(8); printBufferInfo(bb);// w w w . ja v a2s . co m for (int i = 50; i < 58; i++) { bb.put((byte) i); } printBufferInfo(bb); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer buf = ByteBuffer.allocate(10); buf.putShort(0, (short) 123); buf.get(0); // 0 buf.get(1); // 123 }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); System.out.println(bbuf.hasArray()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); System.out.println(bbuf.isDirect()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); System.out.println(bbuf.hashCode()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); ByteBuffer buf = bbuf.asReadOnlyBuffer(); System.out.println(buf.hashCode()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); System.out.println(bbuf.arrayOffset()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); ByteBuffer bb = bbuf.duplicate(); System.out.println(bb.equals(bb)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.putShort(2, (short) 123); ByteBuffer bb = bbuf.duplicate(); System.out.println(bb.compareTo(bb)); }