get My Address as InetAddress - Java Network

Java examples for Network:Network Address

Description

get My Address as InetAddress

Demo Code


//package com.java2s;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getMyAddress());
    }/*from  ww w  .ja  v  a  2 s  . co  m*/

    public static InetAddress getMyAddress() throws UnknownHostException {
        return InetAddress.getLocalHost();
    }
}

Related Tutorials