List of usage examples for java.nio ByteBuffer capacity
public final int capacity()
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.put("java2s.com".getBytes(), 0, 2); ByteBuffer bbuf1 = ByteBuffer.allocate(10); bbuf1.put(bbuf);// w w w .j a va2 s . c om System.out.println(Arrays.toString(bbuf1.array())); }
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); ByteOrder byteOrder = bbuf.order(); System.out.println(byteOrder); }
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.slice(); System.out.println(Arrays.toString(bb.array())); }
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(Arrays.toString(bbuf.array())); bbuf.mark();/*from www.jav a 2s . c om*/ bbuf.reset(); System.out.println(Arrays.toString(bbuf.array())); }
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); bbuf.order(ByteOrder.LITTLE_ENDIAN); ByteOrder byteOrder = bbuf.order(); System.out.println(byteOrder); }
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(Arrays.toString(bb.array())); }
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.compact(); System.out.println(Arrays.toString(bb.array())); }
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.put((byte) 0xFF); bbuf.position(5);//from ww w.j a v a2 s . co m bbuf.put((byte) 0xFF); int pos = bbuf.position(); int rem = bbuf.remaining(); bbuf.limit(7); bbuf.rewind(); }
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.order(ByteOrder.BIG_ENDIAN); bbuf.put("java2s.com".getBytes()); System.out.println(Arrays.toString(bbuf.array())); }
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.order(ByteOrder.LITTLE_ENDIAN); bbuf.put("java2s.com".getBytes()); System.out.println(Arrays.toString(bbuf.array())); }