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