Base64 decoding using JDK6 only

后端 未结 4 858
迷失自我
迷失自我 2020-12-29 04:37

This question with regard to JDK 5 says, there is no implementation provided with JDK 5, but JDK 6 is supposed to have a sun.misc.Base64Decoder.

As far

4条回答
  •  余生分开走
    2020-12-29 05:22

    Just like Joachim Sauer said in a previous comment JDK1.6 already comes bundled with it's own Base64 implementation (sun.misc.*), here's an example:

    String toEncode = "Encoding and Decoding in Base64 Test";
    //Encoding in b64
    String encoded = new BASE64Encoder().encode(toEncode.getBytes());
    System.out.println(encoded);
    //Decoding in b64
    byte[] decodeResult = new BASE64Decoder().decodeBuffer(encoded);
    System.out.println(new String(decodeResult));
    

提交回复
热议问题