Q:
How to create a file on the hard disk by using File class object?
Answer
We can use the following method call:
boolean createNewFile();
This method creates a new file on the HD.
If a file is already existing with the name given in the constructor then this method does not creates file on HD.
If file is successfully created then this method returns true.
If file is already existing on the HD then this method returns false.
This method may throw IOException whenever IO error is generated while creating file on HD.
View answer
Workspace
Report Error
Discuss