Back to course home
0% completed
Java Program to Create a New File
In Java, creating a new file on the file system is commonly done using the File
class from the java.io
package. This lesson demonstrates how to create a new file using the createNewFile()
method, explains the syntax, and discusses the basic error handling required when working with file operations.
Syntax to Create a New File
-
File Class: The
File
class represents a file or directory path in the file system. It does not create a physical file until you call an appropriate method. -
Constructor:
File file = new File("filename.txt");
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible