private static String recursiveSearch ( java . io . File dir , String fileName ) { for ( String name : dir . list ( ) ) { java . io . File file = new java . io . File ( dir . getAbsolutePath ( ) + "/" + name ) ; if ( name . compareTo ( fileName ) == 0 ) return file . getAbsolutePath ( ) ; if ( file . isDirectory ( ) ) { String filePath = recursiveSearch ( file , fileName ) ; if ( filePath != null ) return filePath ; } } return null ; }
Recursive method for searching file path .