首页 > 代码库 > java读取文件内容

java读取文件内容

获取文件内容

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();       

 

java读取文件内容