| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
- import
- tomcat
- GIT
- context
- 단축키
- grep
- xargs
- vscode
- netsh
- IntelliJ
- maVen
- find
- resource
- plugin
- port
- 네트워크
- Windows 10
- web.xml
- Quartz
- lsof
- Eclipse
- Mac
- profile
- Windows
- 줄바꿈 문자
- VirtualBox
- bash
- JavaScript
- ssh
- Source
- Today
- Total
develog
java file copy test 본문
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TestMain {
public static void main(String[] args) {
System.out.println("START");
System.out.println("-----------------------------------");
fileCopyTest("assets/aa.zip", "assets/bb.zip");
fileCopyTest("assets/aa.txt", "assets/bb.txt");
fileCopyTest("assets/aa.jpg", "assets/bb.jpg");
fileCopyTest("assets/aa.xls", "assets/bb.xls");
fileCopyTest("assets/aa.ppt", "assets/bb.ppt");
fileCopyTest("assets/aa.docx", "assets/bb.docx");
fileCopyTest("assets/aa.swf", "assets/bb.swf");
System.out.println("-----------------------------------");
System.out.println("END");
}
private static void fileCopyTest(String sourceFile, String targetFile) {
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(sourceFile);
out = new FileOutputStream(targetFile);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = in.read(buffer)) > -1) {
out.write(buffer, 0, len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (out != null) out.close();
} catch (IOException e) {
}
try {
if (in != null) in.close();
} catch (IOException e) {
}
}
}
}
'Dev > Java' 카테고리의 다른 글
| cmd 에서 jar 만들기 (0) | 2012.06.13 |
|---|---|
| 줄바꿈 문자 (0) | 2012.06.13 |
| [java] Calendar, 1년전, 한달전, 하루전 (0) | 2012.05.11 |
| SimpleDateFormat (0) | 2012.05.10 |
| Thread (0) | 2012.05.10 |