Java Path Relative nio get(File basePath, String... relatives)

Here you can find the source of get(File basePath, String... relatives)

Description

get

License

Open Source License

Declaration

public static Path get(File basePath, String... relatives) 

Method Source Code


//package com.java2s;
/*//from w w  w . ja  v a2s.c o m
 * Copyright (C) 2014-2015 CS-SI (foss-contact@thor.si.c-s.fr)
 * Copyright (C) 2014-2015 CS-Romania (office@c-s.ro)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see http://www.gnu.org/licenses/
 */

import java.io.File;

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static Path get(File basePath, String... relatives) {
        if (relatives == null || relatives.length == 0) {
            return basePath.toPath();
        }
        return Paths.get(basePath.getAbsolutePath(), relatives);
    }

    public static Path get(Path basePath, String... relatives) {
        if (relatives == null || relatives.length == 0) {
            return basePath;
        }
        return Paths.get(basePath.toAbsolutePath().toString(), relatives);
    }
}

Related

  1. checkNormalizedRelative(String path)
  2. combinePaths(String baseDir, String relativePath)
  3. getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)
  4. getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
  5. getFileRelativeFolders(Path basePath, Path filePath)
  6. getOptionalPathRelativeToMavenProjectRoot(File absoluteFile)