Work need such a function, the following is the implementation code, such as input "friends", the output / u0b67 / ucb53public class UnicodeByteUtil {public static void main (String [] args) {UnicodeByteUtil instance = new UnicodeByteUtil (); BufferedReader reader = new BufferedReader (NEW INPUTSTREAMREADER (System.IN)); string line; try {while ((line = reader.readline ())! = null) {if (line.trim (). Equals ("q")) System.exit 0); string s = instance.getbytes (line); system.out.println ("bytes:" s); //system.out.println ("line :" );}} catch (ooexception e) { E.PrintStackTrace ();}}
String getBytes (string s) {Try {stringbuffer out = new stringbuffer (""); byte [] bytes = s.getbytes ("unicode"); for (int i = 2; i