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 bbuf = ByteBuffer.allocate(10); int capacity = bbuf.capacity(); // 10 System.out.println(capacity); bbuf.put("java2s.com".getBytes(), 0, 2); System.out.println(Arrays.toString(bbuf.array())); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer buf = ByteBuffer.allocate(15); FloatBuffer fbuf = buf.asFloatBuffer(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ByteBuffer buf = ByteBuffer.allocate(15); ShortBuffer sbuf = buf.asShortBuffer(); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asDoubleBuffer().put(99471142);//from w w w . j a v a2 s.c o m System.out.println(bb.getDouble()); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asFloatBuffer().put(994.7F);// w w w . jav a 2 s .c om bb.rewind(); System.out.println(bb.getFloat()); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asDoubleBuffer().put(9947.1142);// w ww .j a va 2 s .co m System.out.println(bb.getDouble(0)); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asLongBuffer().put(99472342341142L); bb.rewind();/*from ww w . ja v a2 s.com*/ System.out.println(bb.getLong()); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asDoubleBuffer().put(9947.1142);/* w w w. j a va2 s . co m*/ System.out.println(bb.getDouble()); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asCharBuffer().put("java2s.com"); char c = bb.getChar(1); System.out.print(c + " "); }
From source file:Main.java
public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(BSIZE); bb.asShortBuffer().put((short) 471142); System.out.println(bb.getShort(0)); }