File tree 1 file changed +27
-0
lines changed
app/src/processing/app/helpers
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
package processing .app .helpers ;
2
2
3
3
import java .io .*;
4
+ import java .util .ArrayList ;
4
5
import java .util .Arrays ;
5
6
import java .util .List ;
6
7
import java .util .Random ;
@@ -188,4 +189,30 @@ public static String readFileToString(File file) throws IOException {
188
189
}
189
190
}
190
191
}
192
+
193
+ /**
194
+ * Recursively find all files in a folder with the specified extension
195
+ *
196
+ * @param folder
197
+ * @param extensions
198
+ * @return
199
+ */
200
+ public static List <File > listAllFilesWithExtension (File folder , String ... extensions ) {
201
+ List <File > result = new ArrayList <File >();
202
+ for (File file : folder .listFiles ()) {
203
+ if (file .isDirectory ()) {
204
+ result .addAll (listAllFilesWithExtension (file , extensions ));
205
+ continue ;
206
+ }
207
+
208
+ for (String ext : extensions ) {
209
+ if (file .getName ().endsWith (ext )) {
210
+ result .add (file );
211
+ break ;
212
+ }
213
+ }
214
+ }
215
+ return result ;
216
+ }
217
+
191
218
}
You can’t perform that action at this time.
0 commit comments