package com.StringTest; import java.nio.charset.StandardCharsets; import java.util.Arrays; public class StringToByte { public static void main(String[] args) { String str1 = "abc123"; //String转byte[] byte[] bytes = str1.getBytes(StandardCharsets.UTF_8); System.out.println(Arrays.toString(bytes)); //byte[]转String String s = new String(bytes); System.out.println(s); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)