• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using createNewFile() or PrintWriter class to create a file  RSS feed

 
Achint Verma
Greenhorn
Posts: 12
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a doubt regarding whether using createNewFile is optional if later in the code I am using a PrintWriter statement. Please see the code snippet below.



Please correct me if I am wrong. Thank you.
[EDIT] : Wrapped long line
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting your requirement here as you are not checking if the file and directory exists already. So I assume your code does not rely on the existence of the file.
If you just want to write to an file then PrintWriter creates it for you if its not already there and provided it can create that file. Same holds true for createNewFile().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!