title: URISyntaxException Illegal character in query
body: <p>I am trying to open a link in default browser. I have used the following code.</p>
  
  <pre><code>String myUrl = "http://www.example.com/engine/myProcessor.jsp?Type=A Type&amp;Name=1100110&amp;Char=!"; 
  
          try {
              Desktop.getDesktop().browse(new URI(myUrl));
          } catch (IOException err) {
              setTxtOutput("Error: "+err.getMessage());
          } catch (URISyntaxException err) {      
              setTxtOutput("Error: "+err.getMessage());
          } catch (Exception err) {
              setTxtOutput("Error: "+err.getMessage());
          }
  </code></pre>
  
  <p>I am getting <strong>URISyntaxException</strong> Illegal character in query at index</p>
  
  <p>I think this is because of characters such as <strong>?</strong>, <strong>&amp;</strong> and <strong>!</strong> in my URL. I tried using:</p>
  
  <pre><code>URLEncoder.encode(myUrl, "UTF-8");
  </code></pre>
  
  <p>But this gives me another error. </p>
  
  <pre><code>Failed to open http%3A%2F%2Fwww.example.com%2F........... 
  The system cannot find the file specified.
  </code></pre>
  
  <p>Please can you tell me how to correct the <strong>URISyntaxException Illegal character</strong> error.</p>