자바 base64 encode()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:49 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

자바 base64_encode()
import java.util.Base64;
public class MyClass {
    public static void main(String args[]) {
        System.out.println( new String(Base64.getEncoder().encode("This is an encoded string".getBytes())) );
        System.out.println( new String(Base64.getEncoder().encode("★A가あ中".getBytes())) );
        // VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
        // 4piFQeqwgOOBguS4rQ==
    }
}
private static String base64_encode(String str) {
	return new String(Base64.getEncoder().encode(str.getBytes()));
}
private static String base64_encode(byte[] bytes) {
	return new String(Base64.getEncoder().encode(bytes));
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}