code: private boolean isPrivateIp(String address) {
      InetAddress ip;
      try {
        ip = InetAddress.getByName(address);
      } catch (UnknownHostException e) {
        return false;
      }
  
      return ip.isLoopbackAddress() || ip.isLinkLocalAddress() || ip.isSiteLocalAddress();
    }
docs: Determine whether or not the provided address is private.