Here you can find the source of encodeUtf8(byte[] bytes)
public static String encodeUtf8(byte[] bytes)
//package com.java2s; /*/*from w w w .j ava 2s. c o m*/ * Copyright Gergely Nagy <greg@webhejj.hu> * * Licensed under the Apache License, Version 2.0; * you may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 */ import java.io.UnsupportedEncodingException; public class Main { public static final String UTF8 = "UTF-8"; /** @return bytes converted to UTF-8 string, catching * UnsupportedEncodingException since this is a pretty basic encoding */ public static String encodeUtf8(byte[] bytes) { try { return bytes == null ? null : new String(bytes, UTF8); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Could not convert bytes to UTF-8 string", e); } } }