Java Long to IP Address long2ip(long ipLong)

Here you can find the source of long2ip(long ipLong)

Description

longip

License

Open Source License

Declaration

public static String long2ip(long ipLong) 

Method Source Code

//package com.java2s;

public class Main {

    public static String long2ip(long ipLong) {
        // long ipLong = 1037591503;
        long mask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 };
        long num = 0;
        StringBuffer ipInfo = new StringBuffer();
        for (int i = 0; i < 4; i++) {
            num = (ipLong & mask[i]) >> (i * 8);
            if (i > 0)
                ipInfo.insert(0, ".");
            ipInfo.insert(0, Long.toString(num, 10));
        }/*from  w ww .j a va 2s  .  c  o m*/
        return ipInfo.toString();
    }
}

Related

  1. long2ip(long address)
  2. long2ip(long ip)
  3. long2ip(long ip)
  4. long2ip(long ip)
  5. long2ip(long ip)
  6. long2IP(long ipLong)
  7. long2IP(long proper_address)
  8. long2IpAdress(long src)
  9. longToIp(long address)