How do I create a new directory?
Category: java.io, viewed: 1656 time(s).
package org.kodejava.sample.java.io; import java.io.File; public class CreateDirectoryExample { public static void main(String[] args) { // Create an abstract directory File file = new File("kodejava"); // Create the directory by calling mkdir() method. This // method return true if and only if the directory was // created. If false is returnned no directory is created // because for instance the directory was already exists. if (file.mkdir()) { System.out.println("Directory = " + file.getAbsolutePath() + "."); } else { System.out.println("No directory was created."); } } } |
Here is the result of the program:
Directory = D:\Data\Projects\2005\kodejava-samples\kodejava.
Can't find what you are looking for? Join our FORUMS and ask some questions!
Related Examples
- How do I store properties as XML file?
- How do I load properties from XML file?
- How do I convert InputStream to String?
- How do I convert string into InputStream?
- How do I get an exception stack trace message?
- How do I use Console class to read user input?
- How do I store objects in file?
- How do I use DataInputStream and DataOutputStream?
- How do I use RandomAccessFile class?
- How do I create a directories recursively?
- How can I get current working directory?
- How can I change a file attribute to writable?
- How can I change a file attribute to read only?
- How do I append data to a text file?
- How do I use LineNumberReader class to read file?
- How do I check for a directory?
- How do I get total space and free space of my disk?
- How do I rename a file or directory?
- How do I check if a file is hidden?
- How do I get the content of a directory?
Most Viewed Examples
Latest Code Examples
Categories
100 Top & Latest
Latest Jobs
Blog Entries
Forums Entries
- Google Chrome
- Re: Importing and scanning the text
- Re: What Java books have you read?
- Re: How to create exe file
- How to create exe file
- Re: What Java books have you read?
- Infix expression
- Importing and scanning the text
- Re: I want to reduce the size of a JPG image
- MOVED: I want to reduce the size of a JPG image
