처음 시도 할 때 URL의 파일이 존재하는지 확인한 다음 다운로드하십시오. 그러나 그것은 나에게 "주"sun.net.ftp.FtpProtocolException 스레드에서url openstream에 연결이 너무 많습니다.
예외를 발생시킵니다 : 환영 메시지 : 421 너무 많은 연결 (2) 내가 알고있는 경우에이 IP
에서, 난 항상 연결을 닫습니다 하지만 어쨌든 충돌이 발생합니다.
private boolean exists(String URLName) throws MalformedURLException, IOException {
boolean result = false;
URL url = new URL(URLName);
input = url.openStream();
input.close();
result = true;
return result;
}
private void downloadTheFile(String path, String name) throws MalformedURLException, IOException {
input.close();
input = new URL(path).openStream();
try {
OutputStream out = new FileOutputStream(name + ".pdf");
byte buf[] = new byte[4096];
for (int n = input.read(buf); n > 0; n = input.read(buf)) {
out.write(buf, 0, n);
}
} finally {
out.close();
input.close();
}
}
누구든지 나를 도와 줄 수 있습니까?
루프에서?''downloadTheFile을 (전화하는거야 어떻게 말해 줄 수 있습니까? – hexafraction