1 6 7 package SOFA.Connector.EEG.fileutil; 8 9 14 public class Delete { 15 16 17 private Delete() { 18 } 19 20 public static void delete(java.io.File path) throws DeleteException { 21 if (path.isDirectory()) { 22 deleteDirectory(path); 23 } else { 24 deleteFile(path); 25 } 26 } 27 28 protected static void deleteDirectory(java.io.File path) throws DeleteException { 29 java.io.File [] list=path.listFiles(); 30 for (int i=0;i<list.length;i++) { 31 if (list[i].isDirectory()) { 32 deleteDirectory(list[i]); 33 if (!list[i].delete()) { 34 throw new DeleteException("Can't delete directory '"+list[i]+"'."); 35 } 36 } else { 37 deleteFile(list[i]); 38 } 39 } 40 } 41 42 protected static void deleteFile(java.io.File path) throws DeleteException { 43 if (!path.delete()) { 44 throw new DeleteException("Can't delete file '"+path+"'."); 45 } 46 } 47 } 48 | Popular Tags |