/**
?*?下載文件到本地?
?*/
public?static?void?downloadPicture(String?imageUrl,?String?filename){??
????URL?url;
try?{
url?=?new?URL(imageUrl);
??//打開網絡輸入流
????DataInputStream?dis?=?new?DataInputStream(url.openStream());
????//建立一個新的文件
????FileOutputStream?fos?=?new?FileOutputStream(new?File(filename));
????byte[]?buffer?=?new?byte[1024];
????int?length;
????//開始填充數據
????while((length?=?dis.read(buffer))>0){
???? fos.write(buffer,0,length);
????}
????dis.close();
????fos.close();
}?catch?(Exception?e)?{
e.printStackTrace();
}
??
}
?*?下載文件到本地?
?*/
public?static?void?downloadPicture(String?imageUrl,?String?filename){??
????URL?url;
try?{
url?=?new?URL(imageUrl);
??//打開網絡輸入流
????DataInputStream?dis?=?new?DataInputStream(url.openStream());
????//建立一個新的文件
????FileOutputStream?fos?=?new?FileOutputStream(new?File(filename));
????byte[]?buffer?=?new?byte[1024];
????int?length;
????//開始填充數據
????while((length?=?dis.read(buffer))>0){
???? fos.write(buffer,0,length);
????}
????dis.close();
????fos.close();
}?catch?(Exception?e)?{
e.printStackTrace();
}
??
}