• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find computers dynamic IP address  RSS feed

 
Con Lu
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the following code I can find the IP
address of my computer on my home network:
import java.net.*;
public class LocalHostDemo{
public static void main(String args[]){
System.out.println("Looking up local host");
try{
InetAddress localAddress = InetAddress.getLocalHost();
System.out.println("IP address : " + localAddress.getHostAddress());
}
catch(UnknownHostException uhe){
System.out.println("Error - unable to resolve localhost");
}
}
}
How can I find my computer's dynamic IP address provided by my ISP?
Thanks,
 
Brusk Baran
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, you can use
where here processName refers to "net view" or "ipconfig" in Win2k + xp platform and ipconfig also in Linux architecture.
Then parse the output to an InputStream and readln().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!