title: jsoup to check if a link exsists
body: <p>I want to check if a link exists, if does get the homepage.</p>
  
  <pre><code>Document document = Jsoup.connect(link).get();
  </code></pre>
  
  <p>The issue with this is some times I get :</p>
  
  <pre><code>Exception in thread "main" java.nio.charset.UnsupportedCharsetException: X-MAC-ROMAN
      at java.nio.charset.Charset.forName(Unknown Source)
      at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:86)
      at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:469)
      at org.jsoup.helper.HttpConnection.get(HttpConnection.java:147)
  </code></pre>
  
  <p>I got the related question answered by balu that:</p>
  
  <pre><code>Document doc = Jsoup.parse(new URL(link).openStream(), "ISO-8859-1", link);
  </code></pre>
  
  <p>should be used when the char encoding is different.</p>
  
  <p>But how can I get this working in a case I want to do page validation.</p>
  
  <p>I will get link from user:</p>
  
  <p>than I try </p>
  
  <pre><code>Document document = Jsoup.connect(link).get();
  </code></pre>
  
  <p>It gives exception when the char encoding is not default.</p>