Here you can find the source of getHostName(String addr)
public static String getHostName(String addr)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getHostName(String addr) { if (!isRawAddress(addr)) return addr; try {/* w ww. j a v a2 s.com*/ return InetAddress.getByAddress(toRawAddress(addr)).getHostName(); } catch (UnknownHostException e) { return addr; } } public static boolean isRawAddress(String addr) { return addr.matches("(\\d+).(\\d+).(\\d+).(\\d+)"); } public static byte[] toRawAddress(String addr) { byte[] address = new byte[4]; String[] s = addr.split("\\."); for (int i = 0; i < 4; i++) { address[i] = (byte) Integer.parseInt(s[i]); } return address; } }