How to parse a URIs like this in Java http://translate.google.com/#zh-cn|en| you __java

Source: Internet
Author: User

Original: Http://stackoverflow.com/questions/1828641/how-to-parse-a-uri-like-this-in-java


I ' m trying to parse the following uri:http://translate.google.com/#zh-cn|en| you

But got this error message:

Java.net.URISyntaxException:Illegal character in fragment at index 34:http://translate.google.com/#zh-cn|en| you at
        Java.net.uri$parser.fail (uri.java:2809) at
        Java.net.uri$parser.checkchars (uri.java:2982) at
        Java.net.URI $Parser. Parse (uri.java:3028)

It S has problem with the "|" character, if I get rid of the "|", and the last Chinese char isn't causing any problem, What ' s the right way to handle this? The pipe character is  "considered unsafe"  for use in URLs. Can fix it by replacing the | With its encoded hex equivalent, which would is "%7c"

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.