Here you can find the source of longToIp(long address)
Parameter | Description |
---|---|
address | the long value representing the IP address. |
public static int[] longToIp(long address)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . ja v a 2s .c o m * A convenient method that accepts an IP address represented as a * long and returns an integer array of size 4 representing the same * IP address. * @param address the long value representing the IP address. * * @return An int[] of size 4. */ public static int[] longToIp(long address) { int[] ip = new int[4]; for (int i = 3; i >= 0; i--) { ip[i] = (int) (address % 256); address = address / 256; } return ip; } }