Here you can find the source of decode(final byte[] binaryValue, final Charset charset)
public static String decode(final byte[] binaryValue, final Charset charset)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* ww w . j av a2 s . c o m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static String decode(final byte[] binaryValue, final Charset charset) { final CharsetDecoder decoder = charset.newDecoder(); try { final ByteBuffer bbuf = ByteBuffer.wrap(binaryValue); final CharBuffer cbuf = decoder.decode(bbuf); return cbuf.toString(); } catch (final CharacterCodingException e) { return null; } } /** * Converts a char[] to String. */ public static String toString(final char[] c) { return new String(c); } /** * Converts a char[][] to String, where segments are separated by '.'. */ public static String toString(final char[][] c) { final StringBuilder sb = new StringBuilder(); for (int i = 0, max = c.length; i < max; ++i) { if (i != 0) { sb.append('.'); } sb.append(c[i]); } return sb.toString(); } /** * Converts a char[][] and a char[] to String, where segments are separated by '.'. */ public static String toString(final char[][] c, final char[] d) { if (c == null) { return new String(d); } final StringBuilder sb = new StringBuilder(); for (final char[] element : c) { sb.append(element); sb.append('.'); } sb.append(d); return sb.toString(); } }