The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Maybe it's too late, maybe it's not want you want, buttt.

Posted by Gabriel on July 20, 2001 at 7:37 AM

> Hi all
> I am trying to connect to a website and get the details on the page.
> I know i have to use the java.net.* class, but i don't know how to use this and connect
> Does anyone have a sample code that might help me???

> thank heaps
> Kavitha

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

public class readURLTest
{
public static void main (String args[])

{
try
{
URL address=null;
DataInputStream dis=null;
address=new URL("http://www/ipdevel.ro");
dis=new DataInputSream(address.openStream());

String line=dis.readLine();

while(line!=null)
{
System.out.println(line);
line=dis.readline();
}
}catch(IOException e)
{
System.out.println("Bla bla bla:"+e.getMessage());
}

}
}

or if you want an Applet sample make a class wich extends Applet make an URL use getAppletContext().showDocument(address);
where addres it is the URL like in my sample




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us