Class IPConvert

java.lang.Object
com.reve.utils.ip.IPConvert

public class IPConvert extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    longToBytes(long ip)
    Convert the long ip address to byte array ip address.
    static int
    longToBytes(long ip, byte[] result, int index)
    Append the byte array representation of given long ip address into the given byte array.
    static String
    longToIp(long ip)
    Convert the long ip address to String ip address.
    static String
    longToString(long ip)
    Convert the long ip address to String ip address.
    static long
    Convert the string ip address to String ip address.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IPConvert

      public IPConvert()
  • Method Details

    • longToIp

      public static String longToIp(long ip)
      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

      public static long stringToLong(String ip)
      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

      public static String longToString(long ip)
      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