Java Path Resolve nio resolve(Path directory, String... parts)

Here you can find the source of resolve(Path directory, String... parts)

Description

Resolves the Path to the file or directory under the directory/parts[0]/parts[1]/.../parts[n].

License

Open Source License

Parameter

Parameter Description
directory root directory for resolve
parts parts of the path relative to directory

Return

resolved Path

Declaration

public static Path resolve(Path directory, String... parts) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.nio.file.Path;

public class Main {
    /**//from w  w  w .j  ava 2  s  . co m
     * Resolves the Path to the file or directory under the <code>
     * directory/parts[0]/parts[1]/.../parts[n]</code>.
     *
     * @param directory root directory for resolve
     * @param parts parts of the path relative to directory
     * @return resolved Path
     */
    public static Path resolve(Path directory, String... parts) {
        Path current = directory;
        for (String part : parts) {
            current = current.resolve(part);
        }
        return current;
    }
}

Related

  1. getResolvableFilePath(String path)
  2. resolve(final Optional parent, final String child)
  3. resolve(Path base, String one, String... more)
  4. resolve(Path file, Path srcDir, Path destDir)
  5. resolve(Path path1, Path path2)
  6. resolve(Path target, Collection paths)
  7. resolve(Path workingDir, List paths, String file)