아주 단순하게 처리 했다.
import java.io.*;
import java.net.*;
import java.nio.file.*;
private void downloadfile() {
String urlpath = “http://www.test.com/test.mp3";
String localpath = "c:\test\test.mp3";
try(InputStream in = new URL(urlpath).openStream()){
Files.copy(in, Paths.get(localpath), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
댓글 없음:
댓글 쓰기