Java Path get parent path

Description

Java Path get parent path

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

public class Main {

  public static void main(String[] args) {
    Path p1 = Paths.get("C:", "myData", "Main.java");

    System.out.println(p1);//from   w w w .  ja  v a2 s.c o m

    Path parent = p1.getParent();

    System.out.println(parent);
  }
}



PreviousNext

Related