title: How to parse a URI like this in Java
body: <p>I'm trying to parse the following URI : <a href="http://translate.google.com/#zh-CN|en|%E4%BD%A0" rel="noreferrer">http://translate.google.com/#zh-CN|en|你</a></p>
  
  <p>but got this error message : </p>
  
  <pre><code>java.net.URISyntaxException: Illegal character in fragment at index 34: http://translate.google.com/#zh-CN|en|你
          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)
  </code></pre>
  
  <p>It's having problem with the "|" character, if I get rid of the "|", the last Chinese char is not causing any problem, what's the right way to handle this ?</p>
  
  <p>My method look like this :</p>
  
  <pre><code>  public static void displayFileOrUrlInBrowser(String File_Or_Url)
    {
      try { Desktop.getDesktop().browse(new URI(File_Or_Url.replace(" ","%20").replace("^","%5E"))); }
      catch (Exception e) { e.printStackTrace(); }
    }
  </code></pre>
  
  <p>Thanks for the answers, but BalusC's solution seems to work only for an instance of the url, my method needs to work with any url I pass to it, how would it know where's the starting point to cut the url into two parts and only encode the second part ?</p>