请问关于域名的问题?

请问关于域名的问题?,第1张

strUrl为文件地址,fileName为文件在本地的保存路径,试试吧~
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();
}
}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10878879.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-12
下一篇2023-05-12

发表评论

登录后才能评论

评论列表(0条)

    保存