티스토리 뷰
public static void main(String[] args) throws IOException {
long startTime = System.currentTimeMillis();
String path = "파일경로";
String copyPath = "파일경로";
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(path);
fos = new FileOutputStream(copyPath);
int res = -1; //파일의 끝에 도달하면 -1반환
while((res = fis.read()) != -1){ //읽어오는 메서드(read)
fos.write(res); //읽어온 값을 작성하는 메서드(write)
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if(fis != null){
fis.close();
}
if(fos != null){
fos.close();
}
}
long endTime = System.currentTimeMillis();
System.out.println("소요시간 : "+(endTime - startTime));
}
'Back > Java' 카테고리의 다른 글
[JAVA] 이미지 리사이징 (0) | 2017.08.03 |
---|---|
[JAVA] I/O - URL클래스, PrintWriter (0) | 2016.02.03 |
[JAVA] I/O - File입출력 - BufferedInputStream, BufferedOutputStream (파일복사 예제) (0) | 2016.02.03 |
[JAVA] 배열 (0) | 2013.11.30 |
[JAVA] LOG4J - 펌 (0) | 2013.09.27 |