• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting IP Address  RSS feed

 
Gil Li
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello people..

is there any possibility to get a IP address of paticular website in Java.I have tried using InetAddress package in Java.net . But I did not get..Please give me idea
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gilli,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum...
 
Richard Sargent
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

You might want to try looking again at InetAddress and also having a look at getByName() and getHostAddress()

The following snippet may be of some inspiration...



Obviously, it's best to use Try .. Catch to allow for (eg) UnknownHostException
You can print out hostIP or display it in some gui.
Hope this is of some assistance,
Rich
 
David Gospel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GILLI

This display name doesn't comply to the JavaRanch naming rules described here

We require your display name to be two words: your first name, a space, then your last name. Obviously short first name (like that above) is not allowed. Accounts with invalid display names get deleted, often without warning.

If you want to get help from this community, we require that you follow the rules of the community.

Thanks, Anna
[ May 31, 2004: Message edited by: Anna Kapricornikova ]
 
Anjanesh Lekshminarayanan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your two lines worked Richard no doubt.
I just wanted to know why this doesn't work ?

java.net.InetAddress ip=new java.net.InetAddress();
ip.getHostAddress()

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!