Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

IP numbers

  Asked By: Lewis    Date: May 02    Category: Java    Views: 966

Is there a library function that lets me do:

int value = add_one_to_ip( "" ) ;

System.out.print ( value );

gives :

Of course if the function can do impressive things with the subnet mask and
incrementing the network number when the highest ip is reached, that would be



1 Answer Found

Answer #1    Answered By: Silk Choco     Answered On: Dec 03

Well 1 I use the following code snippet to get ip :

private String getIP()
// This try will give the Public IP Address of the Host.
URL url = new URL("http://automation.www.example.com/n09230945.asp");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String ipAddress = new String();
ipAddress = (in.readLine()).trim();

if (!(ipAddress.length() > 0))
InetAddress ip = InetAddress.getLocalHost();
return ((ip.getHostAddress()).trim());
catch(Exception ex)
return "ERROR";
System.out.println("IP Address is : " + ipAddress);

External ip address can be obtained via http://www.ip-details.com/ too .

Didn't find what you were looking for? Find more on IP numbers Or get search suggestion and latest updates.