일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 공부
- Project
- orcle
- 객체지향프로그래밍
- jsp
- 객제지향프로그래밍
- 프로젝트
- 코딩
- DB
- CSS
- 테이블
- html
- UI
- 오라클
- 웹프로그래밍
- squery
- 데이터베이스
- 프로그래밍
- 자바
- web
- 객체지향
- 공부를열심히
- 주말이다..
- 객제지향
- Java
- 웹
- javascript
- ERWin
- sql
- Oracle
Archives
- Today
- Total
햄찌개
JAVA - 입출력 - image 카피 예제 본문
public class ex_imgCopy_0928 {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos =null;
try {
fis=new FileInputStream("d:/D_Other/Tulips.jpg");
fos = new FileOutputStream("d://D_Other/복사본_Tulips.jpg");
int c;
long start = System.currentTimeMillis();
while ((c=fis.read())!=-1) {
fos.write(c);
}
long end = System.currentTimeMillis();
System.out.println(end-start); // 파일복사 걸린 시간
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Buffer 사용
public class ex_imgCopyBuffer_0928 {
public static void main(String[] args) {
FileInputStream fis = null;
BufferedOutputStream bos = null;
FileOutputStream fos =null;
try {
fis=new FileInputStream("d:/D_Other/Tulips.jpg");
fos = new FileOutputStream("d://D_Other/복사본_Tulips.jpg");
bos = new BufferedOutputStream(fos,5);
int c;
long start = System.currentTimeMillis();
while ((c=fis.read())!=-1) {
bos.write(c);
}
long end = System.currentTimeMillis();
System.out.println("복사에 걸린 시간 : "+(end-start)); // 파일복사 걸린 시간
fis.close();
bos.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
'고급 JAVA' 카테고리의 다른 글
JAVA - InetAddress - IP주소 받아오는 예제 (0) | 2020.09.29 |
---|---|
JAVA - 입출력 - 호텔 관리 프로그램 예제 (0) | 2020.09.29 |
JAVA - 입출력 - Serializable인터페이스 (0) | 2020.09.29 |
JAVA - 입출력 - 객체입출력 보조 스트림 예제 (0) | 2020.09.29 |
JAVA - 입출력 - 프린터 기능 제공 보조 스트림 예제 (0) | 2020.09.29 |