public void download(String url, String destination) {
BufferedOutputStream localBufferedOutputStream = null;
URLConnection localURLConnection = null;
InputStream localInputStream = null;
try {
URL localURL = new URL(url);
localBufferedOutputStream = new BufferedOutputStream(new FileOutputStream(destination));
localURLConnection = localURL.openConnection();
localInputStream = localURLConnection.getInputStream();
byte[] arrayOfByte = new byte[1024];
int i;
while ((i = localInputStream.read(arrayOfByte)) != -1) {
localBufferedOutputStream.write(arrayOfByte, 0, i);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (localInputStream != null) {
localInputStream.close();
}
if (localBufferedOutputStream != null) {
localBufferedOutputStream.close();
}
} catch (IOException localIOException3) {
System.out.println(localIOException3);
}
}
}
내 응용 프로그램을 디버깅 중이며 조금 느립니다. 내 인터넷인지 궁금해. 이것은 자바에서 파일을 다운로드하는 적절한 방법입니까? 파일은 26MB입니다.자바에서 파일을 다운로드하는 가장 좋은 방법일까요?
웹 브라우저에서 동일한 파일을 다운로드하면 어떻게됩니까? – skaffman
자바 좋아해 : 정확하고 명확하지 않은 언어 – TheLQ