Here you can find the source of getHostIP()
public static String getHostIP()
//package com.java2s; /**/*from ww w. ja v a2s. c o m*/ * Archivists' Toolkit(TM) Copyright ? 2005-2008 Regents of the University of California, New York University, & Five Colleges, Inc. * All rights reserved. * * This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL) * version 1.0 (http://www.opensource.org/licenses/ecl1.php) * * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ECL license for more details about permissions and limitations. * * * Archivists' Toolkit(TM) * http://www.archiviststoolkit.org * info@archiviststoolkit.org * * Created by IntelliJ IDEA. * @author: Nathan Stevens * Date: Nov 26, 2008 * Time: 11:08:31 AM */ import java.net.InetAddress; public class Main { /** * Method to return the IP address of the host computer * @return The IP address of the host computer */ public static String getHostIP() { try { InetAddress thisIp = InetAddress.getLocalHost(); return thisIp.getHostAddress(); } catch (Exception e) { e.printStackTrace(); return "No IP Found"; } } }