Re: A programme to receive the HTML code from a URL

From: KrOoSh (harrietcl_at_hotmail.com)
Date: 04/30/04

  • Next message: KrOoSh: "Re: Problem with storing Cookies"
    Date: 30 Apr 2004 00:19:43 -0700
    
    

    Could it be a timeout while reading response?

    Perhaps you would like to try HttpClient as well. It takes care of
    many aspects while connecting to a site, worth taking a look at it =)

    "XMLSDK" <xmlsdk@yahoo.com.hk> wrote in message news:<40912e0f_2@rain.i-cable.com>...
    > I have written a programme to receive the HTML code from a URL
    > http://www.pru.com.hk/
    > But I dunno why it doesn't work. It can only receive the beginning few
    > lines:
    >
    > <!-- i n clude file="BB.asp" -->
    >
    > And the remaining cannot be obtained. Can anyone help me with this problem?
    > Thank you.
    >
    >
    > import java.io.*;
    > import java.net.URL;
    > import java.net.URLConnection;
    >
    > public class App {
    >
    > public static void main(String[] args) {
    > BufferedReader br = null;
    > try
    > {
    > URL url = new URL("http://www.pru.com.hk/");
    > URLConnection urlConn = url.openConnection();
    > InputStreamReader isr = new InputStreamReader(urlConn.getInputStream());
    > br = new BufferedReader(isr);
    >
    > String str;
    > while ((str = br.readLine()) != null)
    > {
    > System.out.println(str);
    > }
    > }
    > catch (IOException e)
    > {
    > System.err.println(e);
    > }
    > finally
    > {
    > try
    > {
    > if (br != null) br.close();
    > }
    > catch (IOException e)
    > {
    > System.err.println(e);
    > }
    > }
    > }
    > }


  • Next message: KrOoSh: "Re: Problem with storing Cookies"