"Java" Java Base64 encoding and decoding

Source: Internet
Author: User
Tags base64

Reference Address: http://blog.csdn.net/zhou_kapenter/article/details/62890262

Requirement: jdk1.8+ Use Java Native Tool class to implement

"Here to show the encoding and decoding of the string into the byte[] implementation of that file, how does the sample file be encoded for storage?" Reference: Http://www.cnblogs.com/sxdcgaq8080/p/8404404.html "

Import java.util.Base64;


Final Base64.decoder Decoder = base64.getdecoder (); Final Base64.encoder Encoder = base64.getencoder (); Final String text = "string literal"; Final byte [] Textbyte = Text.getbytes ("UTF-8"); // Coding Final String Encodedtext = encoder.encodetostring (textbyte); System.out.println (encodedtext); // decoding System.out.println (new String (Decoder.decode (Encodedtext), "UTF-8"));

Java Java base64 encoding and decoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.