java-Network Programming-using Urldecoder and Urlencoder

Source: Internet
Author: User

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

Related Article

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.