@@ -268,22 +268,32 @@ private ArrayList<String> getAllFilesInArchiveDirectory() {
268
268
269
269
// Check if the directory exists and is indeed a directory
270
270
if (directory .exists () && directory .isDirectory ()) {
271
- // List all files and directories in the specified path
272
- File [] files = directory .listFiles ();
273
- assert (files != null );
274
- ArrayList <String > result = new ArrayList <>();
275
- for (File file : files ) {
276
- // add file name if it is a json file
277
- if (isJson (file )) {
278
- result .add (file .getName ());
279
- }
280
- }
281
- return result ;
271
+ // Get all files and directories in the specified path
272
+ return getAllJsonFiles (directory );
282
273
} else {
274
+ // Return an empty list if the directory does not exist
283
275
return new ArrayList <>();
284
276
}
285
277
}
286
278
279
+ /**
280
+ * Gets all the json file name from a directory of given Path
281
+ * @param directory The file path to the directory
282
+ * @return An array list of all json file name
283
+ * */
284
+ private ArrayList <String > getAllJsonFiles (File directory ) {
285
+ File [] files = directory .listFiles ();
286
+ assert (files != null );
287
+ ArrayList <String > result = new ArrayList <>();
288
+ for (File file : files ) {
289
+ // add file name if it is a json file
290
+ if (isJson (file )) {
291
+ result .add (file .getName ());
292
+ }
293
+ }
294
+ return result ;
295
+ }
296
+
287
297
/**
288
298
* checks if the given file is a json file.
289
299
* @param file the file to check
@@ -292,6 +302,8 @@ private boolean isJson(File file) {
292
302
return file .isFile () && file .getName ().toLowerCase ().endsWith (".json" );
293
303
}
294
304
305
+
306
+
295
307
private String getStringWithPrefix (String word , String command ) {
296
308
if (word .length () <= 1 ) {
297
309
return command ;
0 commit comments