File oldfile =new File("C:/Users/Boomiraj/Desktop/palani.txt");
File newfile =new File(oldfile.getAbsoluteFile()+".tmp");
/*if(oldfile.renameTo(newfile)){
System.out.println("Rename succesful");
}else{
System.out.println("Rename failed");
}*/
try {
FileUtils.copyFile(oldfile, newfile);
if(oldfile.delete()){
System.out.println("File deleted");
}
if(newfile.renameTo(oldfile)){
System.out.println("File rename");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File newfile =new File(oldfile.getAbsoluteFile()+".tmp");
/*if(oldfile.renameTo(newfile)){
System.out.println("Rename succesful");
}else{
System.out.println("Rename failed");
}*/
try {
FileUtils.copyFile(oldfile, newfile);
if(oldfile.delete()){
System.out.println("File deleted");
}
if(newfile.renameTo(oldfile)){
System.out.println("File rename");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
No comments:
Post a Comment