Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problrm in creation of file and dircectory  RSS feed

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i run this program ,there is no such file "work.txt" and test directory in C: drive.But the Book says that it should create an instance of "work.txt" by using File class
the programe is:-
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ashok Pradhan:
When i run this program ,there is no such file "work.txt" and test directory in C: drive.But the Book says that it should create an instance of "work.txt" by using File class
the programe is:-


Which book are you referring? ( Quote your sources when asking a question)
You need to use File.createNewFile() method to create a file if it does not exist.
Note: The target directory should exist before calling the above method. If it does not exist, use mkdirs() method on the File instance referring to the directory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!