Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java get ip address

import java.awt.*;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

class Main
{
  public static void main(String args[]) throws IOException
  {
    InetAddress ip;
	String hostname;
	ip = InetAddress.getLocalHost();
	hostname = ip.getHostName();
    System.out.println("Current IP address : " + ip + "
" +
                "current Hostname : " + hostname);
  }
}
 
PREVIOUS NEXT
Tagged: #java #ip #address
ADD COMMENT
Topic
Name
7+5 =