Creating a New File - Java File Path IO

Java examples for File Path IO:File Operation

Description

Creating a New File

Demo Code

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
  public static void main(String[] args) {
    Path newfile = FileSystems.getDefault().getPath(
        "C:/folder1/folder2/2010/my.txt");

    try {//w  w w.  j av  a 2  s  . c o m
      Files.createFile(newfile);
    } catch (IOException e) {
      System.err.println(e);
    }
  }
}

Result


Related Tutorials