public final class NetHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
EMAIL_ADDRESS
This pattern matches valid E-mail addresses
|
static Pattern |
FQDN_HOST_NAME
Checks domain names.
|
static Pattern |
IP_ADDRESS
This pattern may be used to find a valid ip address in a string.
|
static Pattern |
LAX_FQDN_HOST_NAME
Checks domain names.
|
static int |
MAXIMUM_PORT
Field MAXIMUM_PORT (65535)
|
static int |
MAXIMUM_RESTRICTED_PORT
Field MAXIMUM_RESTRICTED_PORT (1023)
|
static int |
MINIMUM_PORT
Field MINIMUM_PORT (0)
|
static Pattern |
URL
Looks for standard, simple URL's not contained by any real delimiters.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canBindPort(int port)
This method will indicate whether or not a server socket can be created
on the provided port or not, if not, most likely another process already
has it bound and is listening on it.
|
static boolean |
canGetIPForHostName(String hostName)
Determines if you can get an IP for a host name
|
static String |
getBestFQDNMatch(String hostName)
Determines a FQDN for the specified host name.
|
static String |
getLocalHostIP()
Gets the local host IP
|
static String |
getPrettyHostName(String hostName)
Gets a pretty version of a host name that cleans up capitalization
|
static boolean |
isActiveHostName(String hostName)
Determines if a host name is acceptable.
|
static boolean |
isActiveIP(String ipAddress)
Determines if an IP is acceptable.
|
static boolean |
isIPv6LiteralAddress(String src)
Determines if IPV6 literal address
|
static boolean |
isLocalHostName(String hostName)
Determines if a host name is a reference to the local machine
|
static boolean |
isPortBound(String host,
int port)
This method will indicate whether or not a port is bound at the specified
host
|
static boolean |
isPortOpen(String host,
int port)
This method will indicate whether or not a port is open at the specified
host
|
static boolean |
isRestrictedPort(String port) |
static boolean |
isValidEmail(String email)
Determines if an E-mail is acceptable
|
static boolean |
isValidFQDNHostName(String hostName)
Determines if a host name is acceptable.
|
static boolean |
isValidIP(String ipAddress)
Determines if an IP is acceptable.
|
static boolean |
isValidIP(String ipAddress,
boolean allowIPV6)
Determines if an IP is acceptable.
|
static boolean |
isValidLaxFQDNHostName(String hostName)
This check is almost the same as isValidFQDNHostName except certain
characters that are allowed inside a domain (such as underscores)
are allowed even though those are invalid by the exact network
definition of a valid FQDN that would work outside a domain.
|
static boolean |
isValidURL(String url)
Determines if a URL is acceptable.
|
static boolean |
isValidURL(String url,
boolean allowIPV6)
Determines if a URL is acceptable.
|
public static final Pattern URL
public static final Pattern FQDN_HOST_NAME
public static final Pattern LAX_FQDN_HOST_NAME
public static final Pattern IP_ADDRESS
Matcher is created from this pattern, the
following results may be seen:
| String | matcher.matches() |
matcher.find() |
matcher.group( 0 ) |
|---|---|---|---|
| ip address | false | false | |
| 209.247.228.221 | true | true | 209.247.228.221 |
| 247.228.221 | false | false | |
| www.utexas.edu (128.83.40.145) | false | true | 128.83.40.145 |
| 064.157.107.097.045 | false | true | 064.157.107.097 |
| 256.4.2.43 | false | false | |
| -4.3.2.1 | false | true | 4.3.2.1 |
public static final Pattern EMAIL_ADDRESS
public static final int MINIMUM_PORT
public static final int MAXIMUM_PORT
public static final int MAXIMUM_RESTRICTED_PORT
public static boolean isValidURL(String url)
url - URL to examinepublic static boolean isValidURL(String url, boolean allowIPV6)
url - URL to examineallowIPV6 - whether to allow IPV6public static String getPrettyHostName(String hostName)
hostName - original host namepublic static String getLocalHostIP()
public static boolean isLocalHostName(String hostName)
hostName - host namepublic static boolean isValidFQDNHostName(String hostName)
hostName - host name to examinepublic static boolean isValidLaxFQDNHostName(String hostName)
hostName - host name to examineisValidFQDNHostName( String )public static boolean canGetIPForHostName(String hostName)
hostName - host name to examinepublic static boolean isActiveHostName(String hostName)
hostName - host name to examinepublic static boolean isValidIP(String ipAddress)
ipAddress - IP address to examinepublic static boolean isValidIP(String ipAddress, boolean allowIPV6)
ipAddress - IP address to examineallowIPV6 - whether to allow IPV6public static boolean isActiveIP(String ipAddress)
ipAddress - IP address to examinepublic static boolean isRestrictedPort(String port)
public static boolean isPortOpen(String host, int port)
host - host name to checkport - port to checkpublic static boolean canBindPort(int port)
port - port to checkpublic static boolean isPortBound(String host, int port)
host - host name to checkport - port to checkpublic static boolean isValidEmail(String email)
email - E-mail to examinepublic static String getBestFQDNMatch(String hostName)
hostName - host name to convert to FQDNpublic static boolean isIPv6LiteralAddress(String src)
src - String representing an IPv6 address in textual format? Copyright 2013 BMC Software, Inc.