Class NetUtils


  • public class NetUtils
    extends Object
    • Method Detail

      • getHostnameOrAddress

        public static String getHostnameOrAddress()
        Get the hostname or IP address.
        Returns:
        The hostname if available, otherwise a dotted quad address. Returns null if neither can be determined.
      • findOpenPort

        public static int findOpenPort()
                                throws IOException
        Find an open port.
        Returns:
        an open port
        Throws:
        IOException
      • findOpenPort

        public static int findOpenPort​(int basePort)
        Find the first open port from default port in an incremental order.
        Parameters:
        basePort -
        Returns:
        an open port
      • available

        public static boolean available​(int port)
        Checks to see if a specific port is available.
        Parameters:
        port - the port to check for availability