When using Java to move files, the main use of the file class in IO is to use the Renameto method in the file class to implement the move of the file, as follows:
Private Boolean RemoveFile (String filename,string destinationfloderurl) {File File = new file (fileName);
File Destfloder = new file (Destinationfloderurl); Check that the target path is legitimate if (destfloder.exists ()) {if (Destfloder.isfile ()) {T His.logger.error (The target path is a file, check the target path.)
");
return false; }}else {if (!destfloder.mkdirs ()) {this.logger.error ("Destination folder does not exist, create Build failed.
");
return false; Check if the source file is legitimate if (File.isfile () &&file.exists ()) {String destination
File = destinationfloderurl+ "/" +file.getname (); if (!file.renameto new file (Destinationfile)) {this.logger.error ("Move file) failed."
");
return false; }}else {This.logger.error ("The file path to be backed up is incorrect and the move failed."
");
return false; This.logger.info ("Moved files successfully" +file.getname () + "to" +destinationfloderurl);
return true;
}