Example usage for java.nio ByteBuffer allocate

List of usage examples for java.nio ByteBuffer allocate

Introduction

In this page you can find the example usage for java.nio ByteBuffer allocate.

Prototype

public static ByteBuffer allocate(int capacity) 

Source Link

Document

Creates a byte buffer based on a newly allocated byte array.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ByteBuffer buf = ByteBuffer.allocate(15);

    IntBuffer ibuf = buf.asIntBuffer();

}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);
    bb.asLongBuffer().put(99472342341142L);
    System.out.println(bb.getLong());

}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);

    bb.asFloatBuffer().put(99471142);/*from  w  w  w  .ja va 2  s  .c  o m*/
    System.out.println(bb.getFloat());
}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);

    bb.asFloatBuffer().put(994.7F);/*from w w  w  .j  ava 2 s. c om*/
    System.out.println(bb.getFloat(0));
}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);
    bb.asIntBuffer().put(99471142);/*from www  .j  a v a  2s  .  c om*/

    System.out.println(bb.getInt(0));
}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);
    bb.asLongBuffer().put(99472342341142L);
    System.out.println(bb.getLong(0));

}

From source file:Main.java

public static void main(String[] args) {
    ByteBuffer bb = ByteBuffer.allocate(BSIZE);

    bb.asFloatBuffer().put(994.7F);//from w w w  . j a v  a 2s . com
    System.out.println(bb.getFloat());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ByteBuffer buf = ByteBuffer.allocate(15);

    LongBuffer lbuf = buf.asLongBuffer();

}

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());
    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);

    CharBuffer cbuf = buf.asCharBuffer();

}