• Post Reply Bookmark Topic Watch Topic
  • New Topic

clarification about InetAddress class and its mehods  RSS feed

bhagavatula indu sekhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

InetAddress inet=InetAddress.getByName(site_name);
System.out.println(inet.getHostName()+" "+inet.getHostAddress()+" "+inet.getCanonicalHostName());
catch(UnknownHostException ue){
catch(Exception e){

doubt1 )

when the input to the program is
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!