下载学习,下载有什么好学的
首先我对下载的理解就是远在服务器的一个文件,想办法通过网络搬到我手机或电脑上面就是下载
好。首先开始最简单的,把一个apk下载到本地
static void download(String urlnet, String filepath) throws IOException {
URL url = new URL(urlnet);
InputStream in = url.openConnection().getInputStream();
byte[] b = new byte[1024];
FileOutputStream out = new FileOutputStream(filepath);
int l;
while ((l = in.read(b)) != -1) {
out.write(b, 0, l);
}
out.close();
in.close();
}
非常的low,因为文件一次性下载,没有校验,不能暂停,单线程,等等弊端,但是它却反应一个下载正常的简单逻辑