Java examples for Internationalization:Charset
convert byte array To String via Charset
//package com.java2s; import java.nio.charset.*; public class Main { public static String convertToString(byte[] bytes, Charset charset) { String ret = new String(bytes, charset); if ((bytes[0] == 0xEF - 256) && (bytes[1] == 0xBB - 256) && (bytes[2] == 0xBF - 256)) { ret = ret.substring(1);//from ww w . j a v a 2s . com } else if ((bytes[0] == 0xFE - 256) && (bytes[1] == 0xFF - 256)) { ret = ret.substring(1); } else if ((bytes[0] == 0xFF - 256) && (bytes[1] == 0xFE - 256)) { ret = ret.substring(1); } return ret; } }