}\r
}\r
}\r
+\r
+ public static final void toDoAll(Set<String> set, ForDoAll fda) throws Exception {\r
+ Iterator<String> di = set.iterator();\r
+ while (di.hasNext()) {\r
+ fda.run(di.next());\r
+ }\r
+ }\r
\r
- public static void toDoAll(String path, ForDoAll fda, int type) throws Exception { // filter of file type can be done in toDo\r
+ public static final void toDoAll(String path, ForDoAll fda, int type) throws Exception { // filter of file type can be done in toDo\r
String[] list = new File(path).list();\r
File test;\r
\r
if (type == DIR || type == BOTH) {\r
- fda.toDo(path);\r
+ fda.run(path);\r
}\r
for (int i = 0 ; i < list.length ; i++) {\r
test = new File(path + File.separator + list[i]);\r
if (test.isDirectory()) {\r
- toDoAll(path + File.separator + list[i], fda, type);\r
+ if (fda.filter(test)) {\r
+ toDoAll(path + File.separator + list[i], fda, type);\r
+ }\r
} else {\r
if (type == FILE || type == BOTH) {\r
- fda.toDo(path + File.separator + list[i]);\r
+ fda.run(path + File.separator + list[i]);\r
}\r
}\r
}\r
}\r
\r
public static interface ForDoAll {\r
- public void toDo(String filepath) throws Exception;\r
+ public void run(String filepath) throws Exception;\r
+ \r
+ public boolean filter(File dir);\r
+ }\r
+ \r
+ public static abstract class Laplace {\r
+ public final void transform(String src, String des) throws Exception {\r
+ Common.string2file(operation(Common.file2string(src)), des);\r
+ }\r
+ \r
+ public abstract String operation(String wholeline);\r
}\r
}\r