@SuppressWarnings("unchecked") public static Map<String,Object> loadFile(String fileName){
  Map<String,Object> props=new HashMap<>();
  if (fileName == null) {
    LOG.warning("Config file name cannot be null");
    return props;
  }
 else   if (fileName.isEmpty()) {
    LOG.warning("Config file name is empty");
    return props;
  }
 else {
    Path path=Paths.get(fileName);
    if (!Files.exists(path)) {
      LOG.fine("Config file " + fileName + " does not exist");
      return props;
    }
    if (!Files.isRegularFile(path)) {
      LOG.warning("Config file " + fileName + " might be a directory.");
      return props;
    }
    LOG.log(Level.FINE,"Reading config file {0}",fileName);
    Map<String,Object> propsYaml=null;
    try {
      FileInputStream fin=new FileInputStream(new File(fileName));
      try {
        Yaml yaml=new Yaml();
        propsYaml=(Map<String,Object>)yaml.load(fin);
        LOG.log(Level.FINE,"Successfully read config file {0}",fileName);
      }
  finally {
        fin.close();
      }
    }
 catch (    IOException e) {
      LOG.log(Level.SEVERE,"Failed to load config file: " + fileName,e);
    }
    return propsYaml != null ? propsYaml : props;
  }
}

@ SuppressWarnings ( "unchecked" ) public static Map < String , Object > loadFile ( String fileName ) { Map < String , Object > props = new HashMap < > ( ) ; if ( fileName == null ) { LOG . warning ( "Config file name cannot be null" ) ; return props ; } else if ( fileName . isEmpty ( ) ) { LOG . warning ( "Config file name is empty" ) ; return props ; } else { Path path = Paths . get ( fileName ) ; if ( ! Files . exists ( path ) ) { LOG . fine ( "Config file " + fileName + " does not exist" ) ; return props ; } if ( ! Files . isRegularFile ( path ) ) { LOG . warning ( "Config file " + fileName + " might be a directory." ) ; return props ; } LOG . log ( Level . FINE , "Reading config file {0}" , fileName ) ; Map < String , Object > propsYaml = null ; try { FileInputStream fin = new FileInputStream ( new File ( fileName ) ) ; try { Yaml yaml = new Yaml ( ) ; propsYaml = ( Map < String , Object > ) yaml . load ( fin ) ; LOG . log ( Level . FINE , "Successfully read config file {0}" , fileName ) ; } finally { fin . close ( ) ; } } catch ( IOException e ) { LOG . log ( Level . SEVERE , "Failed to load config file: " + fileName , e ) ; } return propsYaml != null ? propsYaml : props ; } }
load properties from the given yaml file
