Here you can find the source of longToIPv4(final long ipaddress)
Parameter | Description |
---|---|
ipaddress | a parameter |
public static String longToIPv4(final long ipaddress)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { /*********************************************************************************************** * Convert a long to an IP Address, as four dotted octets. */* ww w . ja v a2 s . c o m*/ * @param ipaddress * * @return String */ public static String longToIPv4(final long ipaddress) { final String SOURCE = "NetworkScannerHelper.longToIPv4() "; final int octet1; final int octet2; final int octet3; final int octet4; final String strIP; //LOGGER.logTimedEvent(SOURCE + "Long [address=" + ipaddress + "]"); octet1 = (int) ((ipaddress & 0x00000000FF000000L) >>> 24); octet2 = (int) ((ipaddress & 0x0000000000FF0000L) >>> 16); octet3 = (int) ((ipaddress & 0x000000000000FF00L) >>> 8); octet4 = (int) (ipaddress & 0x00000000000000FFL); strIP = String.valueOf(octet1) + "." + octet2 + "." + octet3 + "." + octet4; //LOGGER.logTimedEvent(SOURCE + "String [address=" + strIP + "]"); return (strIP); } }