Java Path get file name

Description

Java Path get file name

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  va 2s  .  co m

    Path fileName = p1.getFileName();

    System.out.println(fileName);
  }
}



PreviousNext

Related