Import java.io.UnsupportedEncodingException; class DataProcess { public static byte [] stringToBytes (String STR) { the try { // the specified character string to set this byte sequence encoding a byte array to coexist return str.getBytes ( " . 8-UTF " ); } the catch (UnsupportedEncodingException E) { e.printStackTrace (); } return null ; } public static String bytesToString ( byte [] BS) { the try { // specified by the character set specified byte array to the decoding and construct a new string return new String(bs, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }
reference:
. 1) Java byte in how the byte stream into Chinese
2) Chinese turn unicode, Chinese transfer bytes, unicode bytes java achieve transfer