get all local IP Addresses - Java java.net

Java examples for java.net:IP Address

Description

get all local IP Addresses

Demo Code


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

public class Main {
    /**//w w w. ja v a2 s  .  c om
     * get all local ips
     * @return
     */
    public static InetAddress[] getLocalIps() {
        InetAddress[] ia = null;
        try {
            ia = InetAddress.getAllByName(InetAddress.getLocalHost()
                    .getHostName());
        } catch (Exception e) {
        }
        return ia;
    }
}

Related Tutorials