He元素

Don't be shy just try!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

获取文件内容

picurl = "http://www.baidu.com/data.txt";
URL urlfile = new URL(picurl);  
BufferedReader in = new BufferedReader(new  InputStreamReader(urlfile.openStream(),"utf-8")); //utf-8避免中文乱码
String content="";  
String inputLine =in.readLine();
while(inputLine!=null){  
content +=inputLine; 
inputLine =in.readLine();  
}    
//System.out.println(content);  
out.println(content);  
in.close();       

 

posted on 2017-01-05 17:17  He元素  阅读(335)  评论(0编辑  收藏  举报