Java Files create file

Description

Java Files create file

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

public class Main {
  public static void main(String[] args) {
    Path p1 = Paths.get("Main.txt");
    try {/*from   ww  w .  j  a va  2  s.c  o m*/
      Files.createFile(p1);
      System.out.format("File created: %s%n", p1.toRealPath());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}



PreviousNext

Related