javaswing如何通过WEB链接访问,获得WEB应用内容。
public static String sendURL(String str) {
// TODO Auto-generated method stub
try {
// 构造HttpClient的实例
HttpClient httpClient = new HttpClient();
// 创建GET方法的实例
GetMethod getMethod = new GetMethod(
str);
// 使用系统提供的默认的恢复策略
getMethod。getParams()。setParameter(HttpMethodParams。RETRY_HANDLER,
new DefaultHttpMethodRetryHandler());
try {
// 执行getMethod
int statusCode = httpClient。executeMethod(getMethod);
if (statusCode != HttpStatus。SC_OK) {
System。err。println("Method failed! "
+ getMethod。getStatusLine());
}
// 读取内容
byte[] responseBody = getMethod。getResponseBody();
// 处理内容
return (new String(responseBody));
} catch (HttpException e) {
System。err。println(e。toString());
// 发生致命的异常,可能是协议不对或者返回的内容有问题
e。printStackTrace();
} catch (IOException e) {
// 发生网络异常
System。err。println(e。toString());
e。printStackTrace();
} finally {
// 释放连接
getMethod。releaseConnection();
System。out。println(6);
}
System。out。println(5);
} catch (Exception ex) {
ex。printStackTrace();
}
return null;
}
这个方法能够返回带入的URL的网页内容,需要加httpClient包
swing是java的中用来制作图形界面 web 是网页的
Go语言和Java都可以做web开发,他们有什么区别
Java有常用的Web框架,如SpringMVC、struct2等,Go语言同样也有常用的Web框架,如Beego、Gin等。
Go语言和Java都可以作为web开发的佼佼者。Java的web开发更偏向于应用的广泛,而Go的Web开发更偏向于Web服务器的高性能。
所以一般中小型创业公司,喜欢用Java来搭建,比特币价格对于大型互联网公司更喜欢用Go的高性能的Web框架来搭建,因为大型公司的服务器数量比较多,所以提高单个服务器的性能能够减少很多服务器的数量,从而节约金钱的成本
传智播客开了这个区块链的课程,想了解能做什么的,可以去他们论坛看去,都是很专业的文献
评论