Example usage for java.nio CharBuffer toString

List of usage examples for java.nio CharBuffer toString

Introduction

In this page you can find the example usage for java.nio CharBuffer toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representing the current remaining chars of this buffer.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    CharsetEncoder encoder = charset.newEncoder();

    ByteBuffer bbuf = encoder.encode(CharBuffer.wrap("a string"));

    CharBuffer cbuf = decoder.decode(bbuf);
    String s = cbuf.toString();
}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.wrap("java2s.com");
    System.out.println(cb1.toString());

}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.wrap("java2s.com", 0, 2);
    System.out.println(cb1.toString());

}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.wrap(new char[] { 'j', });
    System.out.println(cb1.toString());

}

From source file:Buffers.java

public static void main(String[] args) {
    try {/*  www  .  ja v  a 2 s .c  om*/
        float[] floats = { 6.61E-39F, 9.918385E-39F };

        ByteBuffer bb = ByteBuffer.allocate(floats.length * 4);

        FloatBuffer fb = bb.asFloatBuffer();
        fb.put(floats);

        CharBuffer cb = bb.asCharBuffer();
        System.out.println(cb.toString());

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.put(new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm', });
    cb1.rewind();/*from   w w w.  ja  v  a 2s . c o  m*/

    CharBuffer cb2 = CharBuffer.allocate(5);
    cb2.put(cb1);
    System.out.println(cb2.toString());
}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.wrap(new char[] { 'j', 'a', 'v', 'a', '2', 's', }, 0, 2);
    System.out.println(cb1.toString());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    CharsetEncoder encoder = charset.newEncoder();

    ByteBuffer bbuf = encoder.encode(CharBuffer.wrap("a string"));

    CharBuffer cbuf = CharBuffer.allocate(10);

    decoder.decode(bbuf, cbuf, true);/*from  w ww  . j  a  v  a2s.c om*/
    String s = cbuf.toString();
}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.put("java2s.com");
    cb1.rewind();//from  ww w. j  a v a2 s .co m

    System.out.println(cb1.toString());
}

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(50);
    cb1.append("java2s.com");
    cb1.rewind();/*from   w w  w.j a va 2s  . co  m*/

    System.out.println(cb1.toString());
}