Here you can find the source of getHostAddresses()
public static InetAddress[] getHostAddresses()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; public class Main { public static InetAddress[] getHostAddresses() { try {//from w w w. jav a2 s. com String hname = getHostName(); if (hname == null) { return null; } return InetAddress.getAllByName(hname); } catch (Exception e) { return null; } } public static String getHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { return null; } } }