title: Java - Throwing an exception if user entered invalid IP address or host name
body: <p>I want to throw an exception that when a user enters an invalid IP address, host name or not a fully qualified domain name it'll bring up an error message.</p>
  
  <p>I'm not too sure whether to use unknownhostexception or IOException.</p>
  
  <p>I tried doing if statement but I don't know what 'invalid' can be in java.</p>
  
  <pre><code>If (addr != ' not a valid IP address, host name, fully qualified domain name or entered something invalid ')
  {
  throw new IOException/UnknownHostException("this is invalid: " + addr); }
  </code></pre>
  
  <p>Can anyone help please? Thanks in advance.</p>