/**
* 下载音频文件
*
* @throws IOException
*/
public void DownloadUnitVoiceFile(URL url, File file) {
URLConnection connection;
try {
connection = url.openConnection();
InputStream inputStream = connection.getInputStream();
FileOutputStream FOS = new FileOutputStream(file);
byte[] bytes = new byte[1024];
int numWrite;
while ((numWrite = inputStream.read(bytes)) != -1) {
FOS.write(bytes, 0, numWrite);
FOS.flush();
}
FOS.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
Log.e("123", "Exception====================>" + e1.toString());
e1.printStackTrace();
}
}
下载音频
最新推荐文章于 2022-10-26 16:00:28 发布