른록노트

[java] base64 String을 byte []로 바꾸는 방법 본문

Programming/[Java]

[java] base64 String을 byte []로 바꾸는 방법

른록 2017. 11. 6. 20:47
import java.io.UnsupportedEncodingException;
import java.util.Base64;

public class Example {

    public static void main(String[] args) {
        try {
            byte[] name = Base64.getEncoder().encode("hello World".getBytes());
            byte[] decodedString = Base64.getDecoder().decode(new String(name).getBytes("UTF-8"));
            System.out.println(new String(decodedString));
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

참고사이트

https://stackoverflow.com/questions/41935207/base64-string-to-byte-in-java

반응형
Comments