色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

怎么將字符串轉換為byte數組

老白2年前203瀏覽0評論

怎么將字符串轉換為byte數組?

1、string 轉 byte[]

String str = "Hello";byte[] srtbyte = str.getBytes();

2、byte[] 轉 string

byte[] srtbyte;String res = new String(srtbyte);System.out.println(res);

3、設定編碼方式相互轉換

String str = "hello";byte[] srtbyte = null;try { srtbyte = str.getBytes("UTF-8"); String res = new String(srtbyte,"UTF-8"); System.out.println(res);} catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace();}

php 打印byte數組,怎么將字符串轉換為byte數組