File Handling in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

File Handling in Java

What's the difference between the use of File f=new File("filename.txt"); and f.createNewFile(); ?

23rd Jun 2020, 3:19 PM
Divlov Jaiswal
Divlov Jaiswal - avatar
1 Answer
+ 2
new File creates just the Java object. And it's implementation allows you to access to filesystem e.g. in order to either open an existing or create a new file.
23rd Jun 2020, 3:21 PM
Sandra Meyer
Sandra Meyer - avatar