Tuesday, September 27, 2011

Create Folder Using JAVA

FolderCreation.java
-----------------------------------------------------
import java.io.File;
/**
 * @author kirankumarg
 *
 */
public class FolderCreation {
     public static String Path = "D:/SampleFolder/";
    //public static String Path = "D:/SampleFolder/subfolder1/subfolder2/subf3/subf4";
    /**
     * @param args
     */
    public static void main(String[] args) {
        File folder = new File(Path);
        //check whether folder exists or not
        if(!folder.exists()){
            folder.mkdir();//use this for a single folder creation
            //folder.mkdirs();//use this for subfolders creation in a Folder
            System.out.println("Folder has been created Successfully ... ");
        }
    }
}

No comments:

Post a Comment