Moving a file into another dir is a one-liner.
See java.io.File#renameTo
Doing what you're doing here, actually copying the content and then deleting the original files is insanity, pure and simple.
I would remove this embarassing attempt at a "tutorial" if I were you.
we can do like this way.....
File file = new File("C:\\A\\file.txt");
if(file.renameTo(new File("C:\\B\\" + file.getName()))){
System.out.println("File is moved successful!");
}else{
System.out.println("File is failed to move!");
}
This can be done with a one-linerAlex Furman July 2, 2011 at 12:19 AM
Moving a file into another dir is a one-liner. See java.io.File#renameTo Doing what you're doing here, actually copying the content and then deleting the original files is insanity, pure and simple. I would remove this embarassing attempt at a "tutorial" if I were you.
renameTopradip garala May 2, 2012 at 4:42 PM
we can do like this way..... File file = new File("C:\\A\\file.txt"); if(file.renameTo(new File("C:\\B\\" + file.getName()))){ System.out.println("File is moved successful!"); }else{ System.out.println("File is failed to move!"); }
Date folder Creationraj August 9, 2012 at 12:59 PM
Take the file from one folder and move it to new folder which created by Date ? can some one help me.
Post your Comment