Can we rename a file say test.txt to test1.txt ?
test.txt
test1.txt
If test1.txt exists will it rename ?
How do I rename it to the alrea
This is an easy way to rename a file:
File oldfile =new File("test.txt"); File newfile =new File("test1.txt"); if(oldfile.renameTo(newfile)){ System.out.println("File renamed"); }else{ System.out.println("Sorry! the file can't be renamed"); }