How to Get Client IP Address Using Java Code
/*
* @author :Anand
*/
package com.anand;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IP{
public static void main(String[] args) {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println("Your IP is====>" + ip.getHostAddress());
} catch (UnknownHostException e) {
System.out.println("catch the exception if Error Come ===>"+e);
e.printStackTrace();
}
}
}
* @author :Anand
*/
package com.anand;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IP{
public static void main(String[] args) {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println("Your IP is====>" + ip.getHostAddress());
} catch (UnknownHostException e) {
System.out.println("catch the exception if Error Come ===>"+e);
e.printStackTrace();
}
}
}
Comments
Post a Comment