
正文
java里面byte数组和String字符串怎么转换
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
//string 转 byte[]String str = "Hello";byte[] srtbyte = str.getBytes();// byte[] 转 stringString res = new String(srtbyte);System.out.println(res);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(); }






