Java-String转Byte数组

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);
    }

}

上一篇:XOR加密


下一篇:Digit sum---打表小能手