private static File [ ] getAllFiles ( String dirName ) { File dir = new File ( dirName ) ; File [ ] files = dir . listFiles ( ) ; // returns files and folders if ( files != null ) { List < File > filteredFiles = new ArrayList < File > ( ) ; for ( File file : files ) { if ( file . isFile ( ) ) { filteredFiles . add ( file ) ; } } return filteredFiles . toArray ( new File [ filteredFiles . size ( ) ] ) ; } else { System . out . println ( dirName + " does not denote a valid directory!" ) ; return new File [ 0 ] ; } }
This method returns the Files found in the given directory