Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help in java networkign code

843802Mar 29 2008
Hi all

i want to display URL name.When some one hit the internet explorar with url then i want ot show url name on applet. Right Now i have code which is working on consol

This is a code of Consol based Url Show:-------

import java.net.*;
import java.io.*;

public class UrlShow{

public static void main(String args[])
{



Reader kbd = new FileReader(FileDescriptor.in);
BufferedReader bufferedKbd = new BufferedReader(kbd);

try
{
String name;
do
{
System.out.print("Enter a hostname or IP address: ");
System.out.flush();

name = bufferedKbd.readLine();

if (name != null)
printRemoteAddress(name);

} while (name != null);

System.out.println("exit");
}
catch (IOException ex)
{
System.out.println("Input error:");
ex.printStackTrace();
}
}

static void printRemoteAddress(String name)
{
try
{
InetAddress addr = InetAddress.getByName(name);
System.out.println("Host name : " + addr.getHostName());
System.out.println("Host IP : " + addr.getHostAddress());

}
catch (UnknownHostException ex)
{
System.out.println("Failed " + name);
}
}
}

Plz Help me how to show url from Internet Explorer..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2008
Added on Mar 29 2008
0 comments
79 views