public static void main(String[] args) throws UnsupportedEncodingException { String str = "www.hellojava.com"; byte [] cs = str.getBytes(); System.out.println((char)cs[0]); //输出第一个字符 String str2 = new String(cs,"UTF-8"); System.out.println(str2); }
输出:
w www.hellojava.com