Collection of encoding and decoding methods

Source: Internet
Author: User

Collect encoding and decoding

 

Base64

 

// Code sun. misc. base64decoder @ test public void T9 () {base64encoder encoder = new base64encoder (); string r = ""; try {r = encoder. encode ("China ". getbytes ("UTF-8");} catch (unsupportedencodingexception e) {e. printstacktrace ();} system. out. println (r); // 5lit5zu9} // decodes sun. misc. base64decoder @ test public void T10 () {base64decoder decoder = new base64decoder (); string r = ""; try {r = new string (decoder. decodebuffer ("5lit5zu9"), "UTF-8");} catch (unsupportedencodingexception e) {e. printstacktrace ();} catch (ioexception e) {e. printstacktrace ();} system. out. println (r); // China}

 

 

URL

// Code java.net. urlencoder @ test public void T11 () {string r = ""; try {r = urlencoder. encode ("China", "UTF-8");} catch (unsupportedencodingexception e) {e. printstacktrace ();} system. out. println (r); // % E4 % B8 % ad % E5 % 9B % BD} // decodes java.net. urldecoder @ test public void T12 () {string r = ""; try {r = urldecoder. decode ("% E4 % B8 % ad % E5 % 9B % BD", "UTF-8");} catch (unsupportedencodingexception e) {e. printstacktrace ();} system. out. println (r); // China}

 

Collection of encoding and decoding methods

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.