Java Path File Name nio detectFilePath(String propertyName, String confFileName)

Here you can find the source of detectFilePath(String propertyName, String confFileName)

Description

detect File Path

License

Apache License

Declaration

private static String detectFilePath(String propertyName, String confFileName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.nio.file.Paths;

public class Main {
    private static final String CONF_DIR = "conf";

    private static String detectFilePath(String propertyName, String confFileName) {
        String configFilePath = System.getProperty(propertyName);

        if (configFilePath == null) {
            String currentDir = Paths.get(".").toAbsolutePath().normalize().toString();
            File confDir = new File(currentDir, CONF_DIR);
            if (confDir.exists() && confDir.isDirectory() && confDir.canRead()) {
                File dbConfigFile = new File(confDir, confFileName);
                if (dbConfigFile.exists()) {
                    configFilePath = dbConfigFile.getAbsolutePath();
                }//from  w w  w  .ja  va 2 s .c om
            }
        } else {
            File dbConfigFile = new File(configFilePath);
            configFilePath = dbConfigFile.getAbsolutePath();
        }

        return configFilePath;
    }
}

Related

  1. appendTargetToBuildFile(String targetName, Path dir)
  2. checkFile(final String friendlyname, final Path file, final boolean isdirectory, final boolean canwrite)
  3. compileAndLoad(Path basePath, String className)
  4. concatFileName(String fileName, Path pathLocation)
  5. convertFilePathToName(Path file)
  6. endsWith(File file, String pathname)
  7. fileName(final Path path)
  8. fileName(final Path thePath)
  9. filterJarContainingClass(Collection jarsPaths, String className)