Here you can find the source of toCharBuffer(final ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | Byte buffer to convert. |
public static CharBuffer toCharBuffer(final ByteBuffer buffer)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; public class Main { /** Default character set for bytes is UTF-8. */ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); /**//from w w w. j ava 2 s . co m * Converts a byte buffer into a character buffer. * * @param buffer Byte buffer to convert. * * @return Character buffer containing UTF-8 string representation of bytes. */ public static CharBuffer toCharBuffer(final ByteBuffer buffer) { return DEFAULT_CHARSET.decode(buffer); } }