Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #12639

The program will choke at the place of (line = reader.readLine()) != null)

From gearss8888@gmail.com
Newsgroups comp.lang.java.programmer
Subject The program will choke at the place of (line = reader.readLine()) != null)
Date 2012-03-03 18:03 -0800
Organization http://groups.google.com
Message-ID <29705069.30.1330826593295.JavaMail.geo-discussion-forums@ynbo9> (permalink)

Show all headers | View raw


I try to use the following method to read pages from Internet, but sometimes the program will choke at the place of (line = reader.readLine()) != null), it tries to read content from internet again and again but still fails to get the line content, then the program stops at this position. How can I solve this problem, if it is possible to use another method the download pages from internet or when the program is choked, if it is possible to stop it and restart the program again?




public  String getHTMLResource(String htmlFile) throws IOException {
		StringBuilder Content =new StringBuilder();
		try {
	String line = null;
			URL url = new URL(htmlFile);
			URLConnection conn = url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			while ((line = reader.readLine()) != null) {
			Content.append(line+"\n");
			}
			reader.close();
		} catch (Exception e) {}
		return Content.toString();
	}

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

The program will choke at the place of (line = reader.readLine()) != null) gearss8888@gmail.com - 2012-03-03 18:03 -0800
  Re: The program will choke at the place of (line = reader.readLine()) != null) Arne Vajhøj <arne@vajhoej.dk> - 2012-03-03 21:13 -0500
    Re: The program will choke at the place of (line = reader.readLine()) != null) gearss8888@gmail.com - 2012-03-04 20:28 -0800
      Re: The program will choke at the place of (line = reader.readLine()) != null) Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 21:28 -0500
  Re: The program will choke at the place of (line = reader.readLine()) != null) Lew <noone@lewscanon.com> - 2012-03-03 23:32 -0800
  Re: The program will choke at the place of (line = reader.readLine()) != null) gearss8888@gmail.com - 2012-03-04 18:26 -0800
  Re: The program will choke at the place of (line = reader.readLine()) != null) Roedy Green <see_website@mindprod.com.invalid> - 2012-03-05 15:27 -0800

csiph-web