public class NetUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_MASK |
static int |
INT_VALUE_127_0_0_1 |
static java.lang.String |
LOCAL_HOST |
static java.lang.String |
LOCAL_IP |
Constructor and Description |
---|
NetUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
downloadBytes(java.lang.String url)
Downloads resource as byte array.
|
static void |
downloadFile(java.lang.String url,
java.io.File file)
Downloads resource to a file, potentially very efficiently.
|
static java.lang.String |
downloadString(java.lang.String url)
Downloads resource as String.
|
static java.lang.String |
downloadString(java.lang.String url,
java.lang.String encoding)
Downloads resource as String.
|
static int |
getIpAsInt(java.lang.String ipAddress)
Returns IP address as integer.
|
static int |
getMaskAsInt(java.lang.String mask) |
static long |
getRemoteFileSize(java.lang.String url)
Get remote file size.
|
static boolean |
isSocketAccessAllowed(int localIp,
int socketIp,
int mask) |
static java.lang.String |
resolveHostName(byte[] ip)
Resolves host name from IP address bytes.
|
static java.lang.String |
resolveIpAddress(java.lang.String hostname)
Resolves IP address from a hostname.
|
static boolean |
validateIPv4(java.lang.String input)
Checks given string against IP address v4 format.
|
public static final java.lang.String LOCAL_HOST
public static final java.lang.String LOCAL_IP
public static final java.lang.String DEFAULT_MASK
public static final int INT_VALUE_127_0_0_1
public static java.lang.String resolveIpAddress(java.lang.String hostname)
public static int getIpAsInt(java.lang.String ipAddress)
public static int getMaskAsInt(java.lang.String mask)
public static boolean isSocketAccessAllowed(int localIp, int socketIp, int mask)
public static boolean validateIPv4(java.lang.String input)
input
- an ip address - may be nullpublic static java.lang.String resolveHostName(byte[] ip)
public static byte[] downloadBytes(java.lang.String url) throws java.io.IOException
java.io.IOException
public static java.lang.String downloadString(java.lang.String url, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.lang.String downloadString(java.lang.String url) throws java.io.IOException
java.io.IOException
public static void downloadFile(java.lang.String url, java.io.File file) throws java.io.IOException
java.io.IOException
public static long getRemoteFileSize(java.lang.String url) throws java.io.IOException
url
- remote file urljava.io.IOException
- JDK-IOExceptionCopyright © 2003-present Jodd Team