public helloWorld() {
System.out.println("this is the hello world test for make directory and delete it");
}
public void createDir(String dir) {
if(dir==null) {
directory = new File("d:/newDir/new/temp");
}
else {
directory = new File(dir);
}
/** create new Directory:
* create new file then use: directory.createNewFile(dir);
* for example: (delete the file d:/cccc/1.txt)
* directory=new File("d:/cccc","1.txt");
* directory.delete();
*/
boolean flagCreate=directory.mkdirs();
}
public void deleteDir(String dir) {
if(dir==null) {
directory = new File("d:/newDir/new/temp");
}
else {
directory = new File(dir);
}
if (directory.exists()&& directory.listFiles().length ==0) {
/* delete the directory if it is blank
in this example it only del the directory "d:\ccccc\a"but the "d:/ccccc" still exist */
boolean flagDelete=directory.delete() ;
System.out.print("Delete Directory: "+ directory.toString() +"--------\n" +flagDelete +"\n");