base64与bytes互换

import java.util.Base64;
public class StringByteArrayExamples 
{
    public static void main(String[] args) 
    {
        //Original byte[]
        byte[] bytes = "hello world".getBytes();
         
        //Base64 Encoded
        String encoded = Base64.getEncoder().encodeToString(bytes);
         
        //Base64 Decoded
        byte[] decoded = Base64.getDecoder().decode(encoded);
         
        //Verify original content
        System.out.println( new String(decoded) );
    }
}
展开阅读全文

没有更多推荐了,返回首页