一、String與char、char[]轉換:ide
String str = "hello world!";編碼
char[] ch = str.toCharArray();//String轉char[]utf-8
String str1 = String.valueOf(ch);//char[]轉Stringget
String str2 = new String(ch);//char[]轉Stringit
char ca = str.charAt(0);//String轉charclass
String str3 = ca + "";//char轉Stringdi
二、String與byte[]轉換:view
String str = "hello world!哈哈";
byte[] bt1 = str.getBytes();//String轉byte[]
byte[] bt2 = str.getBytes("utf-8");//String使用指定編碼轉byte[]
String str1 = new String(bt1);//byte[]轉String
String str2 = new String(bt2,"utf-8");//byte[]使用指定指定編碼轉Stringvi
後續更新中......co