Here you can find the source of getLocalIp()
Parameter | Description |
---|---|
UnknownHostException | an exception |
public static String getLocalIp() throws UnknownHostException
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//from www . ja va 2 s. c o m * Get local IP * * @return * @throws UnknownHostException */ public static String getLocalIp() throws UnknownHostException { String ip = InetAddress.getLocalHost().getHostAddress(); return ip; } }