title: Normalize a String to create a safe URL in Java
body: <p>I'm writing a library in Java which creates the URL from a list of filenames in this way:</p>
  
  <pre><code>final String domain = "http://www.example.com/";
  
  String filenames[] = {"Normal text","Ich weiß nicht", "L'ho inserito tra i princìpi"};
  
  System.out.println(domain+normalize(filenames[0]);
  //Prints  "http://www.example.com/Normal_text"
  System.out.println(domain+normalize(filenames[1]);
  //Prints  "http://www.example.com/Ich_weib_nicht"
  System.out.println(domain+normalize(filenames[2]);
  //Prints  "http://www.example.com/L_ho_inserito_tra_i_principi"
  </code></pre>
  
  <p>Exists somewhere a Java library that exposes the method <code>normalize</code> that I'm using in the code above?</p>
  
  <p>Literature:</p>
  
  <ul>
  <li><a href="https://webmasters.stackexchange.com/questions/498/which-special-characters-are-safe-to-use-in-url">Which special characters are safe to use in url?</a></li>
  <li><a href="https://stackoverflow.com/questions/695438/safe-characters-for-friendly-url">Safe characters for friendly url</a></li>
  </ul>