日期:2014-05-19 浏览次数:20778 次
URL url=new URL("http://www.fjdjh.com/sqx/sqx1.xls");
File excel=file_put_contents("D:\\1.xls",url.openStream());
public static File file_put_contents(String savePath,InputStream is){
File file=new File(savePath);
OutputStream os=null;
try{
os=new FileOutputStream(file);
byte buffer[]=new byte[4*1024];
int len=0;
while((len=is.read(buffer))!=-1){
os.write(buffer,0,len);
}
os.flush();
}
catch(Exception e){
e.printStackTrace();
}
finally{
try{
os.close();
}
catch(Exception e){
e.printStackTrace();
}
}
return file;
}