Package jodd.io
Class NetUtil
java.lang.Object
jodd.io.NetUtil
Network utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]downloadBytes(String url) Downloads resource as byte array.static voiddownloadFile(String url, File file) Downloads resource to a file, potentially very efficiently.static StringdownloadString(String url) Downloads resource as String.static StringdownloadString(String url, Charset encoding) Downloads resource as String.static intgetIpAsInt(String ipAddress) Returns IP address as integer.static intgetMaskAsInt(String mask) static longgetRemoteFileSize(String url) Get remote file size.static booleanisSocketAccessAllowed(int localIp, int socketIp, int mask) static StringresolveHostName(byte[] ip) Resolves host name from IP address bytes.static StringresolveIpAddress(String hostname) Resolves IP address from a hostname.static booleanvalidateIPv4(String input) Checks given string against IP address v4 format.
-
Field Details
-
LOCAL_HOST
- See Also:
-
LOCAL_IP
- See Also:
-
DEFAULT_MASK
- See Also:
-
INT_VALUE_127_0_0_1
public static final int INT_VALUE_127_0_0_1- See Also:
-
ip4RegExp
-
-
Constructor Details
-
NetUtil
public NetUtil()
-
-
Method Details
-
resolveIpAddress
Resolves IP address from a hostname. -
getIpAsInt
Returns IP address as integer. -
getMaskAsInt
-
isSocketAccessAllowed
public static boolean isSocketAccessAllowed(int localIp, int socketIp, int mask) -
validateIPv4
Checks given string against IP address v4 format.- Parameters:
input- an ip address - may be null- Returns:
- true if param has a valid ip v4 format false otherwise
- See Also:
-
resolveHostName
Resolves host name from IP address bytes. -
downloadBytes
Downloads resource as byte array.- Throws:
IOException
-
downloadString
Downloads resource as String.- Throws:
IOException
-
downloadString
Downloads resource as String.- Throws:
IOException
-
downloadFile
Downloads resource to a file, potentially very efficiently.- Throws:
IOException
-
getRemoteFileSize
Get remote file size. Returns -1 if the content length is unknown- Parameters:
url- remote file url- Returns:
- file size
- Throws:
IOException- JDK-IOException
-