//保存文件到本地
private void saveFile(String audioUrl, String targetPath) throws IOException {
URL url = new URL( audioUrl );
InputStream inputStream = url.openStream();
BufferedInputStream in = new BufferedInputStream( inputStream );
BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( targetPath ) );
byte[] bytes = new byte[1024];
int len = 0;
while ((len = in.read( bytes )) != -1) {
out.write( bytes, 0, len );
}
out.close();
in.close();
}
远程的文件保存到本地
最新推荐文章于 2022-03-18 23:45:19 发布