Package com.reve.utils.ip
Class IPConvert
java.lang.Object
com.reve.utils.ip.IPConvert
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]longToBytes(long ip) Convert the long ip address to byte array ip address.static intlongToBytes(long ip, byte[] result, int index) Append the byte array representation of given long ip address into the given byte array.static StringlongToIp(long ip) Convert the long ip address to String ip address.static StringlongToString(long ip) Convert the long ip address to String ip address.static longstringToLong(String ip) Convert the string ip address to String ip address.
-
Constructor Details
-
IPConvert
public IPConvert()
-
-
Method Details
-
longToIp
Convert the long ip address to String ip address.- Parameters:
ip- ip address in long which should be converted.- Returns:
- the converted string representation of ip address
-
longToBytes
public static byte[] longToBytes(long ip) Convert the long ip address to byte array ip address.- Parameters:
ip- ip address in long which should be converted.- Returns:
- the converted byte array of length 4, which represent the ip address.
-
longToBytes
public static int longToBytes(long ip, byte[] result, int index) Append the byte array representation of given long ip address into the given byte array.- Parameters:
ip- ip address in long which should be converted.result- converted ip address will be appended into this byte array.index- starting index of the byte array where ip address should be appended.- Returns:
- the length new index of the byte array after appending the ip address.
-
stringToLong
Convert the string ip address to String ip address.- Parameters:
ip- ip address in String which should be converted.- Returns:
- the converted long representation of ip address
-
longToString
Convert the long ip address to String ip address.- Parameters:
ip- ip address in long which should be converted.- Returns:
- the converted string representation of ip address
-