最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
java如何执行html代码?java执行html代码的实例
时间:2017-02-20 编辑:简简单单 来源:一聚教程网
StringBuffer response = new StringBuffer();
HttpURLConnection connection = null;
try
{
URL url = new URL("http://……");
connection = (HttpURLConnection) url.openConnection();
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String lines;
while((lines = reader.readLine()) != null)
{
if(lines != null && lines.trim().length() > 0)
{
response.append(lines.trim());
}
else
{
continue;
}
}
System.out.println(response.toString());
reader.close();
}
catch(Exception e)
{
throw e;
}
finally
{
if(connection != null)
{
connection.disconnect();
}
}
代码如下 | 复制代码 |
-
上一个: Java各种中文乱码问题及解决方案
相关文章
- HTML是什么 HTML教程 HTML实例 05-04
- html5实现的下雨/下雪实例源码 09-04
- HTML5离线存储归纳及使用实例 08-21
- html5 开发的的俄罗斯方块实例源码 07-19
- 分享一个纯html5制作的时钟源码实例 12-17
- HTMLElement 对象的方法实例 03-12