@Nullable public static String findFileInProvidedPath(String providedPath,String... fileNames){
  if (StringUtil.isEmpty(providedPath)) {
    return "";
  }
  File providedFile=new File(providedPath);
  if (providedFile.exists()) {
    String name=providedFile.getName();
    for (    String fileName : fileNames) {
      if (name.equals(fileName)) {
        return toSystemDependentName(providedFile.getPath());
      }
    }
  }
  if (providedFile.isDirectory()) {
    for (    String fileName : fileNames) {
      File file=new File(providedFile,fileName);
      if (fileName.equals(file.getName()) && file.exists()) {
        return toSystemDependentName(file.getPath());
      }
    }
  }
  providedFile=providedFile.getParentFile();
  if (providedFile != null && providedFile.exists()) {
    for (    String fileName : fileNames) {
      File file=new File(providedFile,fileName);
      if (fileName.equals(file.getName()) && file.exists()) {
        return toSystemDependentName(file.getPath());
      }
    }
  }
  return null;
}

@ Nullable public static String findFileInProvidedPath ( String providedPath , String ... fileNames ) { if ( StringUtil . isEmpty ( providedPath ) ) { return "" ; } File providedFile = new File ( providedPath ) ; if ( providedFile . exists ( ) ) { String name = providedFile . getName ( ) ; for ( String fileName : fileNames ) { if ( name . equals ( fileName ) ) { return toSystemDependentName ( providedFile . getPath ( ) ) ; } } } if ( providedFile . isDirectory ( ) ) { for ( String fileName : fileNames ) { File file = new File ( providedFile , fileName ) ; if ( fileName . equals ( file . getName ( ) ) && file . exists ( ) ) { return toSystemDependentName ( file . getPath ( ) ) ; } } } providedFile = providedFile . getParentFile ( ) ; if ( providedFile != null && providedFile . exists ( ) ) { for ( String fileName : fileNames ) { File file = new File ( providedFile , fileName ) ; if ( fileName . equals ( file . getName ( ) ) && file . exists ( ) ) { return toSystemDependentName ( file . getPath ( ) ) ; } } } return null ; }
returns empty string for empty path . first checks whether provided path is a path of a file with sought - for name . unless found , checks if provided file was a directory . in this case checks existence of child files with given names in order " as provided " . finally checks filename among brother - files of provided . returns null if nothing found .
