public void Download()
{
int byteRead=0;
try
{
URL url=new URL(link);
URLConnection conn=url.openConnection();
InputStream is=conn.getInputStream();
FileOutputStream os=new FileOutputStream(path);
byte[] buffer=new byte[262144];
while((byteRead=is.read(buffer))!=-1)
{
os.write(buffer,0,byteRead);
}
}
catch(MalformedURLException me)
{
me.printStackTrace();
}
catch(IOException ie)
{
ie.printStackTrace();
}
}
保存文件
最新推荐文章于 2021-08-14 17:02:09 发布