
public static void writeFile(String strUrl, String fileName) {
URL url = null;
try {
url = new URL(strUrl);
} catch (MalformedURLException e2) {
e2printStackTrace();
}
InputStream is = null;
try {
is = urlopenStream();
} catch (IOException e1) {
e1printStackTrace();
}
OutputStream os = null;
try {
os = new FileOutputStream( fileName);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = isread(buffer, 0, 8192)) != -1) {
oswrite(buffer, 0, bytesRead);
}
Systemoutprintln("下载成功:"+strUrl);
} catch (FileNotFoundException e) {
eprintStackTrace();
} catch (IOException e) {
eprintStackTrace();
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)