public boolean moveFile(String source, String dest) {
boolean result = false;
FileInputStream inputStream = null;
FileOutputStream outputStream = null;
try {
inputStream = new FileInputStream(source);
outputStream = new FileOutputStream(dest);
} catch (FileNotFoundException e) {
e.printStackTrace();
result = false;
}
FileChannel fcin = inputStream.getChannel();
FileChannel fcout = outputStream.getChannel();
long size = 0;
try {
size = fcin.size();
fcin.transferTo(0, size, fcout);
fcout.close();
fcin.close();
outputStream.close();
inputStream.close();
result = true;
} catch (IOException e) {
e.printStackTrace();
result = false;
}
File f = new File(source);
if (f.delete()) {
result = true;
}
return result;
}
'Java' 카테고리의 다른 글
Apache Commons DBCP 환경설정 값 (0) | 2015.06.10 |
---|---|
Collections를 이용한 List 객체들의 Sorting(정렬) [펌] (0) | 2009.11.26 |
이미지 썸네일 처리 (0) | 2009.11.25 |
불필요한 코딩을 줄이자!(IBM developerWorks) (0) | 2009.04.09 |