Java Path File Name nio initializePath(String... envVarNames)

Here you can find the source of initializePath(String... envVarNames)

Description

initialize Path

License

Open Source License

Declaration

private static void initializePath(String... envVarNames) throws FileNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileNotFoundException;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static final String SUBDIRECTORY = "HookAnyText";
    public static final Map<String, Path> DRICTORIES = new HashMap<>();

    private static void initializePath(String... envVarNames) throws FileNotFoundException {

        String keyEnvVarName = envVarNames[0];

        Path p = DRICTORIES.get(keyEnvVarName);
        if (p != null)
            return;

        String directory = null;/*from www.j a  v  a  2  s .  c o  m*/
        for (int i = 0; i < envVarNames.length && directory == null; ++i) {
            directory = System.getenv(envVarNames[i]);
        }
        if (directory == null) {
            throw new FileNotFoundException("No " + keyEnvVarName + " directory found.");
        }
        p = Paths.get(directory, SUBDIRECTORY);
        new File(p.toString()).mkdirs();
        DRICTORIES.put(keyEnvVarName, p);
    }
}

Related

  1. getSolrCorePath(Path solrHome, String indexName)
  2. getSourceRoot(Path filePath, String pkgName)
  3. getTestDataPath(Class clazz, String name)
  4. getUniqueFileInDirectory(Path dir, String name)
  5. inheritGwtModule(Path path, String inheritableModuleLogicalName)
  6. isExecutableOnPath(String execName)
  7. isHiddenName(Path path)
  8. jobNameFromPath(Path path)
  9. listDocTypeName(Path path)