In the section, you will learn how a directory or subdirectories are created. This program also explains the process of creating all non-existent ancestor directories automatically. We will use the File class to crate the directory.
The File class an abstract representation of file and directory pathnames. File class is used to interact with the files system.
Here is the code for creating directory and all non-existing ancestor directories:
Output of the program:
Directory: test created
Directories: dir1/dir2/dir3 created
This program takes inputs to create a directory "test" and subdirectories "dir1\dir2\dir3". the mkdir( ) method is used to create a single directory while the mkdirs( ) method is used to create multiple subdirectories.
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: April 17, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles