Here you can find the source of decodeBytes(byte[] data, Charset charset, boolean report)
public static CharBuffer decodeBytes(byte[] data, Charset charset, boolean report) throws CharacterCodingException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CodingErrorAction; public class Main { public static CharBuffer decodeBytes(byte[] data, Charset charset, boolean report) throws CharacterCodingException, IOException { CodingErrorAction action = (report) ? CodingErrorAction.REPORT : CodingErrorAction.REPLACE; CharsetDecoder decoder = charset.newDecoder(); decoder.onMalformedInput(action); decoder.onUnmappableCharacter(action); return decoder.decode(ByteBuffer.wrap(data)); }/*from w ww.ja v a 2s.c om*/ }