如何获取网页地址的XML 文件 比如http://localhost:8080/KnowledgeBase/xml/test.xml有个XML文件我JAVA端 如何 读取 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 URL getUrl = new URL("http://localhost:8080/KnowledgeBase/xml/test.xml");HttpURLConnection HttpURLConnection connection = (HttpURLConnection) getUrl .openConnection(); // 进行连接,但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到 // 服务器 connection.connect(); // 取得输入流,并使用Reader读取 BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream())); String lines; while ((lines = reader.readLine()) != null) { System.out.println(lines); } reader.close(); // 断开连接 connection.disconnect(); 菜鸟向大神求教~~~ 在JTabbedPane的页签标题的后面加一个工具栏? 随便举个例子,说明单线程比多线程编程提高性能 怎么在List中添加JPopupMenu? JAVA 程序员一般用什么集成开发工具? static void f(int i)要修改i的值竟然无法做到?这就是java呀?通过包装类也无法直接修改成员变量值,还要重新创建一个对象传回引用,真恶 帮帮我!谢谢 由北京的搞JSP+数据库开发的吗 ?能告诉一下你们的薪水吗? 每天四十分散分贴 包引用的問題,這是為什麼? SQL Server2008 R2 是不是不能进行静态调用?
);
HttpURLConnection
HttpURLConnection connection = (HttpURLConnection) getUrl
.openConnection();
// 进行连接,但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到
// 服务器
connection.connect();
// 取得输入流,并使用Reader读取
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String lines;
while ((lines = reader.readLine()) != null) {
System.out.println(lines);
}
reader.close();
// 断开连接
connection.disconnect();