public static boolean nameExistsInPath ( String name ) { String path = System . getenv ( PATH_ENV_VARIABLE ) ; String [ ] dirs = path . split ( File . pathSeparator ) ; for ( String dir : dirs ) { File dirFile = new File ( dir ) ; if ( ! dirFile . exists ( ) ) continue ; if ( dirFile . isFile ( ) && dirFile . getName ( ) . equals ( name ) ) return true ; else { Iterator < File > files = FileUtils . iterateFiles ( dirFile , null , false ) ; while ( files . hasNext ( ) ) { File curr = files . next ( ) ; if ( curr . getName ( ) . equals ( name ) ) return true ; } } } return false ; }
Check if a file exists in the path