How to create a new file using JAVA ?

By | June 25, 2011

Hi,

For creating a new file using JAVA, use the following code.

import java.io.File;
public class MainClass {

  public static void main(String[] a)throws Exception {

    File myFile = new File("c:\temp\newText.txt");

    myFile.createNewFile();

  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *