How to create a directory and subdirectory in the filesystem using mkdir() in Java

1 Answer

0 votes
package javaapplication1;

import java.io.File;
import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

        File f = new File("d:/programming/source");
        boolean DirectoryCreated = f.mkdirs();

        if (DirectoryCreated) {
            System.out.println("Directory and subdirectory created");
        } else {
            System.out.println("Directory and subdirectory not created");
        }
    }
}

/*
       
run:
 
Directory and subdirectory created
   
 */

 



answered Nov 15, 2016 by avibootz

Related questions

1 answer 205 views
1 answer 217 views
1 answer 187 views
1 answer 180 views
2 answers 276 views
...