title: IP Address to Hostname in Java?
body: <p>My hosts file (C:\WINDOWS\system32\drivers\etc\hosts) has a bunch of IP Address to host name mappings:</p>
  
  <pre><code># Switches
  192.168.200.254       sw-con-ctrl
  192.168.201.253    sw-con-ctrl-2
  192.168.201.254       sw-con-ctrl-1
  # 192.168.188.1       sw-con-ctrl-ylw-1
  # 192.168.189.1       sw-con-ctrl-blu
  192.168.190.62        access-console
  
  # Routers
  192.168.21.1          rtr1
  192.168.22.1          rtr2
  </code></pre>
  
  <p>I am trying to find a way to convert from an IPAddress to the HostName programmatically through Java APIs.</p>
  
  <p>Pseudocode:</p>
  
  <pre><code>IPAddress ip = new IPAddress("192.168.190.62");
  String host = ip.getHost();
  System.out.println(host);  //prints "access-console"
  </code></pre>