esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

How do I create and remove a directory?



import java.io.*;

public class creDelDir {

public static void main(String args[]) {
//Creates the directory named by this abstract pathname.
File f1 = new File("dir1");
f1.mkdir();

/* Creates the directory named by this abstract pathname,
including any necessary but nonexistent parent
directories.
*/
File f2 = new File("dir1/dir2/dir3");
f2.mkdirs();

/* Deletes the file or directory denoted by this abstract
pathname. If this pathname denotes a directory, then the
directory must be empty in order to be deleted.*/
f1.delete();
f2.delete();
}
}


f1.delete does not delete dir1, because it contains subdirectories.
After execution File System will have 'dir1/dir2' directory structure.


Further Information
Author of answer: Kishore Koya

Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.