Here you can find the source of getIPAsString(InetAddress addr)
Parameter | Description |
---|---|
addr | a parameter |
public static String getIPAsString(InetAddress addr)
//package com.java2s; import java.net.InetAddress; public class Main { /**// w w w . j a v a 2 s. c o m * Returns a human readable IP address for the given address. * @param addr * @return */ public static String getIPAsString(InetAddress addr) { byte[] ip = addr.getAddress(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ip.length; i++) { if (i != 0) { sb.append("."); } sb.append(ip[i] & 0xFF); } return sb.toString(); } }