通过对应 的URL地址,读取页面里面的内容

// 通过对应 的URL地址,读取页面里面的内容
	public String getHtmlReadLine(String httpurl) throws Exception {
		String CurrentLine = "";
		String TotalString = "";
		InputStream urlStream;
		String content = "";
		try {
			URL url = new URL(httpurl);
			Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
					"cmproxy.gmcc.net", 8081));

			HttpURLConnection connection = (HttpURLConnection) url
					.openConnection(proxy);
			// HttpURLConnection connection = (HttpURLConnection) url
			// .openConnection();

			connection.connect();
			urlStream = connection.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					urlStream, "gbk"));
			while ((CurrentLine = reader.readLine()) != null) {
				TotalString += CurrentLine;
			}
			content = TotalString;
		} catch (Exception e) {
			throw e;
			// e.printStackTrace();
		}
		return content;

	}

你可能感兴趣的:(exception,String,null,url)