1. String 轉 byte[]
String str = "Hello";//聲明一個字元串
byte[] srtbyte = str.getBytes();//使用string類的getBytes方法進行轉換
2. byte[] 轉 String
srtbyte = str.getBytes("UTF-8");//設定轉換的編碼格式
String res = new String(srtbyte,"UTF-8");
String str = "Hello";//聲明一個字元串
byte[] srtbyte = str.getBytes();//使用string類的getBytes方法進行轉換
srtbyte = str.getBytes("UTF-8");//設定轉換的編碼格式
String res = new String(srtbyte,"UTF-8");