aspose file tools*
The moose likes Java in General and the fly likes Creating a new folder in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating a new folder in java" Watch "Creating a new folder in java" New topic
Author

Creating a new folder in java

William Ross
Greenhorn

Joined: Jul 06, 2006
Posts: 12
How can I create a new folder on my local drive through a Java program? Say for example I wanted C:\test to appear on my C drive after running a program. Thank you.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3652
    
  15
If it's just a single directory use File.mkdir().
If you want to ensure that all parent directories are created as well use File.mkdirs().
See the API for more details.


Joanne
William Ross
Greenhorn

Joined: Jul 06, 2006
Posts: 12
Yea sorry, I should got googled more first. Got it now:

File newFolder = new File(absolute path name);
newFolder.mkdirs();
 
Don't get me started about those stupid light bulbs.
 
subject: Creating a new folder in java