首页 > 代码库 > java之URL(URL,URLConnection)实例
java之URL(URL,URLConnection)实例
import org.junit.Test; public class TestURL { @Test public void readUrl() throws Exception{ URL url = new URL("http://localhost:8088/gress/data/reportData_201401.xml?a=b"); System.out.println(url.getProtocol()); System.out.println(url.getHost()); System.out.println(url.getPort()); System.out.println(url.getPath()); System.out.println(url.getFile()); System.out.println(url.getRef()); System.out.println(url.getQuery()); URLConnection urlConn = url.openConnection(); BufferedReader buffReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); String str = null; while((str = buffReader.readLine()) != null ){ System.out.println(str); } buffReader.close(); } }
java之URL(URL,URLConnection)实例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。