/**
* Delete a single object
* The path of the tempfilepath file is: "d :\\ projectpath \ attach \ HTML \ test.html"
* @ Param Image
* @ Return
*/
Public void deletetempfile (string tempfilepath ){
File file = new file (tempfilepath );
String statenotexsit = tempfilepath + "the file does not exist. deletion failed! ";
String stateerror = tempfilepath + "the file is in use. deletion failed! ";
String statesuccess = tempfilepath + "deleted successfully! ";
If (file. exists ()){
Boolean d = file. Delete ();
If (d ){
System. Out. println (statesuccess );
} Else {
System. Out. println (stateerror );
}
} Else {
System. Out. println (statenotexsit );
}
}
/**
* Delete folders and all contents in the folder
* Dir = new file ("D: \ projectpath \ attach \ html ");
* @ Param Image
* @ Return
*/
Public Boolean deletefolder (File DIR ){
File filelist [] = dir. listfiles ();
Int listlen = filelist. length;
For (INT I = 0; I <listlen; I ++ ){
If (filelist [I]. isdirectory ()){
Deletefolder (filelist [I]);
} Else {
If (! Filelist [I]. Delete ())
Return false;
}
}
If (! Dir. Delete ())
Return false; // Delete the current directory
Else
Return true;
}
/**
* Batch Delete objects
* Tempfilepath is the set of file locations
* @ Return
*/
Public void deletealltemppdffile (arraylist <string> tempfilepath ){
For (INT I = 0; I <tempfilepath. Size (); I ++ ){
File file = new file (tempfilepath. Get (I ));
String statenotexsit = tempfilepath + "the file does not exist. deletion failed! ";
String stateerror = tempfilepath + "the file is in use. deletion failed! ";
String statesuccess = tempfilepath + "deleted successfully! ";
If (file. exists ()){
Boolean d = file. Delete ();
If (d ){
System. Out. println (statesuccess );
} Else {
System. Out. println (stateerror );
}
} Else {
System. Out. println (statenotexsit );
}
}
}