Class NetUtil

java.lang.Object
jodd.io.NetUtil

public class NetUtil extends Object
Network utilities.
  • Field Details

  • Constructor Details

    • NetUtil

      public NetUtil()
  • Method Details

    • resolveIpAddress

      public static String resolveIpAddress(String hostname)
      Resolves IP address from a hostname.
    • getIpAsInt

      public static int getIpAsInt(String ipAddress)
      Returns IP address as integer.
    • getMaskAsInt

      public static int getMaskAsInt(String mask)
    • isSocketAccessAllowed

      public static boolean isSocketAccessAllowed(int localIp, int socketIp, int mask)
    • validateIPv4

      public static boolean validateIPv4(String input)
      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

      public static String resolveHostName(byte[] ip)
      Resolves host name from IP address bytes.
    • downloadBytes

      public static byte[] downloadBytes(String url) throws IOException
      Downloads resource as byte array.
      Throws:
      IOException
    • downloadString

      public static String downloadString(String url, Charset encoding) throws IOException
      Downloads resource as String.
      Throws:
      IOException
    • downloadString

      public static String downloadString(String url) throws IOException
      Downloads resource as String.
      Throws:
      IOException
    • downloadFile

      public static void downloadFile(String url, File file) throws IOException
      Downloads resource to a file, potentially very efficiently.
      Throws:
      IOException
    • getRemoteFileSize

      public static long getRemoteFileSize(String url) throws IOException
      Get remote file size. Returns -1 if the content length is unknown
      Parameters:
      url - remote file url
      Returns:
      file size
      Throws:
      IOException - JDK-IOException