A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Sockets and Internet Protocols
Author
clarification about InetAddress class and its mehods
bhagavatula indu sekhar
Ranch Hand
Joined: Sep 17, 2006
Posts: 34
posted
Feb 05, 2007 06:27:00
0
i am expected to get the domain names of servers that are connected to Internet and keep them in a database.
it has been suggested by some members of this forum to make use of
InetAddress
class.
so just to
test
and know how to use
InetAddress
i wrote the following program
the jdk kit i have is jdk6.0
i need some clarifications about the output of the program.
import java.io.*;
import java.net.*;
import javax.swing.*;
public class Inetdemo {
public static void main(
String
[] args) {
Inetdemo in=new Inetdemo();
}
public Inetdemo(){
String site_name=JOptionPane.showInputDialog("Enter a site name");// accepts input the site name
try{
InetAddress
inet=InetAddress.getByName(site_name);
System.out.println(inet.getHostName()+" "+inet.getHostAddress()+" "+inet.getCanonicalHostName());
}
catch(
UnknownHostException
ue){
ue.printStackTrace();
System.out.println("HostERROR!");
}
catch(Exception e){
e.printStackTrace();
System.out.print("Exception");
}
}
}
doubt1 )
when the input to the program is
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: clarification about InetAddress class and its mehods
Similar Threads
when local machine address is not available ?
problem with socket connecting??
neglecting an exception
How to lock java app for single PC
clarification about InetAddress class and its mehods
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter