Urldecoder and Urlencoder are used to complete the conversion between ordinary strings and application/x-www-form-urlencoded mime strings.
The programming process may involve common strings and related transformations of this particular string, which requires the use of the Urldecoder class and the Urlencoder class
1. The Urldecoder class contains a decoder (string s,string Enc) static method that converts a special string that looks garbled to a normal string.
2. The Urlencoder class contains a encoder (string s,string Enc) static method that converts a normal string to a application/x-www-form-urlencoded mime string.
1 ImportJava.net.URLDecoder;2 ImportJava.net.URLEncoder;3 Public classUrldecoderclass4 {5 Public Static voidMain (string[] args)throwsexception{6 //the application/x-www-form-urleencoded string7 //convert to normal string8String Keyword=urldecoder.decode ("%b7%e8%bf%f1java", "GBK");9 System.out.println (KeyWord);Ten //convert ordinary characters to One //application/x-www-form-urlencoded String AString Urlstr=urlencoder.encode ("Java thought", "GBK"); - System.out.println (URLSTR); - } the}
java-Network Programming-using Urldecoder and Urlencoder