/**
* 파일을 이동시켜주는 메소드
* @param originPath
* @param afterPath
* @param originName
* @param afterName
*/
public void fileMove(String originPath, String afterPath, String originName, String afterName) {
String path = afterPath + "\\"+afterName;
File dir = new File(afterPath);
if(!dir.exists()){
dir.mkdirs();
}
try{
File file = new File(originPath+"\\"+originName);
if(file.renameTo(new File(path))){
// System.out.println(file.getAbsolutePath());
}else{
System.out.println(file.getAbsolutePath());
System.out.println(path);
System.out.println("실패");
return;
}
}catch(Exception e){
e.printStackTrace();
}
}
반응형