try {
FileOutputStream fos = new FileOutputStream("C:\\Users\\user\\Desktop\\HTY\\Copy3.pdf");
is = conn.getInputStream();
byte[] buffer = new byte[1024];
int readBytes;
while ((readBytes = is.read(buffer)) != -1) {
fos.write(buffer, 0, readBytes);
}
fos.close();
System.out.println("파일 다운완료");
} catch (Exception e) {
e.printStackTrace();
}
FileOutputStream() 안에 다운로드 받을 위치를 지정해주면 된다.
파일 명까지 잡아주어야 한다.
| StringBuffer StringBuilder (0) | 2023.02.23 |
|---|---|
| isEmpty() String, Array (0) | 2023.02.22 |
| JAVA Server - Client 서버 클라이언트 연결 (0) | 2022.08.09 |
| JAVA BufferedReader (0) | 2022.08.09 |
| JAVA IO(Input/Output) (0) | 2022.08.09 |