Java InetAddress Create getInetAddress()

Here you can find the source of getInetAddress()

Description

get Inet Address

License

Open Source License

Declaration

public static String getInetAddress() 

Method Source Code


//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 "";
        }
    }
}

Related

  1. getHostAddress(InetAddress host)
  2. getHostName(InetAddress address)
  3. getHostName(InetAddress ia)
  4. getHostNameReliably(final String requestingHost, final InetAddress site, final URL requestingUrl)
  5. getHostNameWithoutDomain(final InetAddress addr)
  6. getInetAddress()
  7. getInetAddress()
  8. getInetAddress()
  9. getInetAddress(final int[] octets, final int offset, final int length)