1. import java.util.Arrays;
    2. public class test {
    3. public static void main(String[] args) {
    4. // String 转 byte[]
    5. String str = "java.lang.UNIXProcess";
    6. byte[] b = str.getBytes();
    7. System.out.println(Arrays.toString(b));
    8. }
    9. }
    1. public class test {
    2. public static void main(String[] args) {
    3. // byte[] 转 String
    4. byte[] b = new byte[]{106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 85, 78, 73, 88, 80, 114, 111, 99, 101, 115, 115};
    5. String s = new String(b);
    6. System.out.println(s);
    7. }
    8. }