public void downloadNet() throws MalformedURLException {
URL url = new URL("webUrl");
try {
URLConnection conn = url.openConnection();
InputStream inStream = conn.getInputStream();
FileOutputStream fs = new FileOutputStream("fileUrl");
byte[] buffer = new byte[1204];
int length = 0;
while ((length = inStream.read(buffer)) != -1) {
fs.write(buffer, 0, length);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
从网络上下载文件
最新推荐文章于 2024-04-27 11:49:29 发布