Basically ;

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

class Main {
    public static void main (String[] args) {
//
try {
    URL url = new URL("http://java.sun.com/index.html";);

    Object content = url.getContent();
    if (content != null) {
        System.out.println("class: " + content.getClass());
        System.out.println("obj: " + content);
    }

    InputStream in = url.openStream();
    if (in != null) {
        for(int c = in.read(); c > 0; c = in.read()) {
            System.out.print((char)c);
        }
    }
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
//
}
}

However I've found with some web pages what use (eg .asp) , you needed to
use a bufferedreader

Justin


> -----Original Message-----
> From: Drew Falkman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 20, 2002 4:22 PM
> To: JRun-Talk
> Subject: Web Page as a stream
>
>
> Hey all-
>
> Does anyone know of a good way to open another Web page and
> process it as a
> stream using Java - similar to what CFHTTP does in ColdFusion?
>
> I want to read a dynamic, XML-compliant Web page from another site and
> perform an XSLT transformation on it and am looking for the best way to do
> it.  Additionally, I could parse a WHOIS result, or use it in other ways.
>
> Thanks,
>
> Drew Falkman
> Author, JRun Web Application Construction Kit
> http://www.drewfalkman.com
> 
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to