Java File create new file

Description

Java File create new file

import java.io.File;
import java.io.IOException;

public class Main {
  public static void main(String[] args) {
    File myFile = new File("Main.java");
    // Create the file
    try {//from   w  w w .  j  a  va 2s  .  c o  m
      boolean fileCreated = myFile.createNewFile();
      System.out.println("file created:"+fileCreated);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}



PreviousNext

Related