Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Java Create Directory - Java Tutorial 
 

In the section of Java Tutorial you will learn how to create directory using java program.

 

Java Create Directory - Java Tutorial

                         

In the section of Java Tutorial you will learn how to create directory using java program. This program also explains the process of creating all non-existent ancestor directories automatically. We will use the class File class to crate the directory.

Class File
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:

import java.io.*;
class CreateDirectory 
{
   public static void main(String args[])
  {
      try{
    String strDirectoy =
"test";
    String strManyDirectories="dir1/dir2/dir3";

    // Create one directory
    boolean success = (new File(strDirectoy)).mkdir();
    if (success) {
      System.out.println("Directory: " + strDirectoy + " created");
    }    
  

    // Create multiple directories
    success = (new File(strManyDirectories)).mkdirs();
    if (success) {
      System.out.println("Directories: " + strManyDirectories + " created");
    }

    }catch (Exception e){//Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }
  }
}

Download the code

                         

» View all related tutorials
Related Tags: c file array class list ui lists method get name using this oo root example where to exam drive store

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

8 comments so far (
post your own) View All Comments Latest 10 Comments:

I'm a trainee s/w engineer.
I want to create an application in java. After completing the project I want to install it as a complete project i.e. java software .But I don't know how to create exe for installation.

Posted by subodh on Wednesday, 07.30.08 @ 19:18pm | #69999

simple but effective example.. very easy to follow

Posted by srikanth on Monday, 12.3.07 @ 17:44pm | #41185

Thank you very much,a really simple and practice example!

Posted by Manuela on Tuesday, 01.9.07 @ 23:43pm | #3072

Wht can I say abt roseindia.net, It is awesome. Excellent course material for beginners, It made me easy to brush-up JAVA, actually I forgot JAVA since I was very much into other application programming.

Now, I m very much confident abt JAVA, Thank U RoseIndia for ur valuable effort.

Posted by Rajee L on Tuesday, 12.19.06 @ 14:27pm | #1231

thank you very much. It's easy to understand.

Posted by arbujung on Thursday, 12.14.06 @ 10:07am | #1003

Thanks a lot it did help :)

Posted by SLizer3D on Saturday, 12.9.06 @ 13:56pm | #687

Its really useful and very easy to knew the basic concepts with out any illusion.Absolutely great feast to the beginners.

Posted by Balakrishnan.R on Wednesday, 12.6.06 @ 20:31pm | #534

It's really nice.Basic flow depicted here really providing track for the begineers to continue and brings confidence in them to proceed further.Keep it up.

Posted by Balakrishnan.R on Wednesday, 12.6.06 @ 20:06pm | #515

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.