code: private String getHostName() {
          try {
              return java.net.InetAddress.getLocalHost().getCanonicalHostName();
          } catch (java.net.UnknownHostException e) {
              return "localhost";
          }
      }
docs: Get the host name.
  
  @return String value of the host name or "localhost" if not able to resolve