Resolve the passed path against the current path's parent path - Java File Path IO

Java examples for File Path IO:Path

Description

Resolve the passed path against the current path's parent path

Demo Code

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

public class Main {
  public static void main(String[] args) {
    // define the fixed path
    Path base = Paths.get("C:/folder1/folder2/folder3/test.txt");

    // resolve sibling test2.txt file
    Path path = base.resolveSibling("test2.txt");
    System.out.println(path.toString());

  }/*from   w w w.  j av a 2 s  .c  om*/
}

Related Tutorials