2个回答
展开全部
public String getHTML(String httpUrl, String Charset) {
String html = "";
try {
URL url = new URL(httpUrl.toString());
StringBuffer document = new StringBuffer();
try {
URLConnection urlCon = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(
new InputStreamReader(urlCon.getInputStream()));
String Result = "";
while ((Result = reader.readLine()) != null) {
document.append(Result);
// System.out.println(Result);
}
html = document.toString();
} catch (IOException e) {
html = "服务未响应";
}
} catch (MalformedURLException e) {
html = "不支持的协议";
}
return html;
}
String html = "";
try {
URL url = new URL(httpUrl.toString());
StringBuffer document = new StringBuffer();
try {
URLConnection urlCon = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(
new InputStreamReader(urlCon.getInputStream()));
String Result = "";
while ((Result = reader.readLine()) != null) {
document.append(Result);
// System.out.println(Result);
}
html = document.toString();
} catch (IOException e) {
html = "服务未响应";
}
} catch (MalformedURLException e) {
html = "不支持的协议";
}
return html;
}
更多追问追答
追问
我需要传递过去的请求参数怎么传递过去了?
追答
附到 httpUrl 这个上面去。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询