Here you can find the source of getInetAddress()
public static String getInetAddress()
//package com.java2s; /*/*from w ww . j a v a2 s .c o m*/ * @(#)CommonUtils.java Jun 30, 2009 * * Copyright 2008 by ChinanetCenter Corporation. * * All rights reserved. * * This software is the confidential and proprietary information of * ChinanetCenter Corporation ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with ChinanetCenter. * */ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getInetAddress() { try { InetAddress inet = InetAddress.getLocalHost(); return inet.getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return ""; } } }