jodd.io
Class NetUtil

java.lang.Object
  extended by jodd.io.NetUtil

public class NetUtil
extends java.lang.Object

Network utilities.


Field Summary
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 Summary
NetUtil()
           
 
Method Summary
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 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 validateHostIp(java.lang.String host)
          Validates IP address given as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_HOST

public static final java.lang.String LOCAL_HOST
See Also:
Constant Field Values

LOCAL_IP

public static final java.lang.String LOCAL_IP
See Also:
Constant Field Values

DEFAULT_MASK

public static final java.lang.String DEFAULT_MASK
See Also:
Constant Field Values

INT_VALUE_127_0_0_1

public static final int INT_VALUE_127_0_0_1
See Also:
Constant Field Values
Constructor Detail

NetUtil

public NetUtil()
Method Detail

resolveIpAddress

public static java.lang.String resolveIpAddress(java.lang.String hostname)
Resolves IP address from a hostname.


getIpAsInt

public static int getIpAsInt(java.lang.String ipAddress)
Returns IP address as integer.


getMaskAsInt

public static int getMaskAsInt(java.lang.String mask)

isSocketAccessAllowed

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

validateHostIp

public static boolean validateHostIp(java.lang.String host)
Validates IP address given as a string.


resolveHostName

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


downloadBytes

public static byte[] downloadBytes(java.lang.String url)
                            throws java.io.IOException
Downloads resource as byte array.

Throws:
java.io.IOException

downloadString

public static java.lang.String downloadString(java.lang.String url,
                                              java.lang.String encoding)
                                       throws java.io.IOException
Downloads resource as String.

Throws:
java.io.IOException

downloadString

public static java.lang.String downloadString(java.lang.String url)
                                       throws java.io.IOException
Downloads resource as String.

Throws:
java.io.IOException

downloadFile

public static void downloadFile(java.lang.String url,
                                java.io.File file)
                         throws java.io.IOException
Downloads resource to a file, potentially very efficiently.

Throws:
java.io.IOException


Copyright © 2003-2012 Jodd Team