下载文件是URL请求外部网址失败怎么办
请求外部网址下载文件
请问各位大佬知道下载文件的时候请求外部HTTP地址无法访问是什么情况吗
以下是我的代码
try {
URL url = new URL(path);//请求的地址
try {
InputStream inputStream = url.openStream();
int available = inputStream.available();
System.out.println(available);
OutputStream outputStream = response.getOutputStream();
response.setContentType("application/x-download");
response.addHeader("Content-Disposition", "attachment;filename="+fileName+"yuyin.wav");
response.addHeader("X-APP-ID", "a7ea6af9aa74d0ffd5ee38435eeb8be4");
response.addHeader("X-APP-KEY", "cb24f2f41860b97be736aa46621a086a");
response.addHeader("X-CTG-Request-Id", IdUtil.randomUUID());
IOUtils.copy(inputStream, outputStream);
outputStream.flush();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
}
}