Java Path File Name nio getConfigurationFilePath(String name)

Here you can find the source of getConfigurationFilePath(String name)

Description

get Configuration File Path

License

Apache License

Declaration

public static Path getConfigurationFilePath(String name) 

Method Source Code


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

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.stream.Stream;

public class Main {
    public static Path getConfigurationFilePath(String name) {
        return getConfigurationDirectoryPath().resolve(name);
    }// w  w w . j  av  a  2s.  c o m

    public static Path getConfigurationDirectoryPath() {
        Path homeDirectory = Paths.get(System.getProperty("user.home"));
        Path defaultConfigurationDirectory = homeDirectory.resolve(".perspective");
        Optional<Path> configurationDirectoryCandidate = Stream
                .of(homeDirectory.resolve(".config").resolve("perspective"), defaultConfigurationDirectory)
                .filter(p -> Files.exists(p)).findFirst();
        return configurationDirectoryCandidate.isPresent() ? configurationDirectoryCandidate.get()
                : defaultConfigurationDirectory;
    }
}

Related

  1. getAllFiles(List fileNames, Path path)
  2. getArtifactName(Path artifactPath)
  3. getBandNameStr(Path filePath)
  4. getClassName(Path pluginImplementationDirectory, Path classFile)
  5. getConfigurationFile(String installPath, String serverName)
  6. getContentPath(Path zipFilePath, String contentFileName)
  7. getDatabaseDirectoryPath(String databaseDirectory, String name)
  8. getDataPath(String filename)
  9. getDeckNameFromFile(final Path deckFile)