how to create directory in java

Solutions on MaxInterview for how to create directory in java by the best coders in the world

showing results for - "how to create directory in java"
Justice
19 Jun 2016
1String path = ...
2File pathAsFile = new File(path);
3
4if (!Files.exists(Paths.get(path))) {
5	pathAsFile.mkdir();
6}
Lena
09 Jan 2021
1package com.mkyong.file;
2
3import java.io.File;
4
5public class CreateDirectoryExample {
6
7    public static void main(String[] args) {
8
9        File file = new File("C:\\Directory1");
10        if (!file.exists()) {
11            if (file.mkdir()) {
12                System.out.println("Directory is created!");
13            } else {
14                System.out.println("Failed to create directory!");
15            }
16        }
17
18        File files = new File("C:\\Directory2\\Sub2\\Sub-Sub2");
19        if (!files.exists()) {
20            if (files.mkdirs()) {
21                System.out.println("Multiple directories are created!");
22            } else {
23                System.out.println("Failed to create multiple directories!");
24            }
25        }
26
27    }
28
29}
Giorgio
15 Sep 2016
1new File("pathToFile").mkdir(); 
Valerio
26 Mar 2018
1// mkdir() method in java example
2import java.io.*;
3public class CreateDirectory
4{
5   public static void main(String[] args)
6   {
7      File directory = new File("D:\\DirectoryExample");
8      if(!directory.exists())
9      {
10         if(directory.mkdir())
11         {
12            System.out.println("Directory is created");
13         }
14         else
15         {
16            System.out.println("Directory not created");
17         }
18      }
19   }
20}
Nola
19 Aug 2019
1// mkdirs() method in java example
2import java.io.File;
3public class CreateDirectoryDemo
4{
5   public static void main(String[] args)
6   {
7      File directory = new File("D:\\DirectoryExample\\subdirectory1\\subdirectory2");
8      if(!directory.exists())
9      {
10         if(directory.mkdirs())
11         {
12            System.out.println("Sub directories created");
13         }
14         else
15         {
16            System.out.println("Sub directories not created");
17         }
18      }
19   }
20}
Michael
29 Feb 2018
1 Path path = Paths.get("/home/mkyong/a/b/c/");
2
3    //java.nio.file.Files;
4    Files.createDirectories(path);
queries leading to this page
how to create folder in java projectwrite a java program to create a foldercreate new progect java by folder existjava creating new folderhow to write a directory in javajava check directory exists and createcreate directory javajava create folder if not existsjava how to create directory if not existcreating folders in javacreate folder if not exist javahow to create a folder file using javahow to createdirectory in javacreate directory using javajava new folderhow to add folder in another folder in javajava create a directorycannot create folder en javajava file class create directoryhow to make directory javacjava io file save to disk create directory if not existjava make directory if not existhow to create an class obeject which is inside a folderjava move file and create folder if not existif directory does not exist create one javacreate folders given a path javajava generate new folderjava creating directorycreate directory in javajava if directory doesn 27t exist create itjava create empty folderhow to create a new folder in javahow to create directory in linux with javacreate a folder using javajava creating foldercreate folder if file des not exsistcreate a folder in javamake directory in javajava create file and directory if not existsjava create new folder with a namecreate new working directory in javajava create dir if not existsjava create folder at program fileshow to create a folder programmatically in javacreate a directoryb javajava create new folderjava file create a directorycreate folder with file name if not exists javawhere java create folders if not existcreate a new directory in javacreate folder with path javacreate a folder if it doesn 27t exist javajava create directory if not existscreate dir if not exist javahow to create out folder javajava program for creating a folderhow create folder in javamake a folder in javajava make a new folderjava make folderhow to make a new directory in javajava file create directorycreate directory and file in javacreate directory if it doesnt exist javacreating folder javajava create folder from pathhow to create a folder javajava create a folder if it does not existcreate folder java if not existhow to create a directory javahow to make a folder with javacreate folder is doesn 27t exist javacreate directory javvacreate empty folder javacreate a directory using java io filehow to create directories without already xists error javacreate directory in project javamaking a directory javacreating a new directory window javacreate folder that doesnt exist in javacheck if folder exists java then createjava creat a foldercreate a new dir in java creating a directory in javajava file create foldercreate a new file and directory if not there javacreate new directory in javajava crate directorycreate directory i javacreate directory in java without mkdirjava exception if directory not exist createjava make directory in windowshow to create a director in javajava create new directorycreate directory if it does not exist javahow to create dynamic directory in javahow create directory in java 8how to create a folder in javajava create folder and file if not existsjava file create dirscheck if folder exists else create javahow to make a folder inside a folder javahow to create folder with javamake dir javacreate directory java filecreate folders that do not exist froma list of file name in a txt file javajava check if folder exists and createmake directory javafile create directory javamake folder in javahow to make directory using javajava how to create folder in file pathcreate directory in local in javajava add file object to directory objectjava does file create directory if not existcreate folder in java examplejava create folder if not exist example codemake file not found after create directory javajava create folderscan you make a normal directory in javacreate folder in java 8java is folder in path not exist createhow to create a new folder in java if existhow to make a new folder in javacreate directory i java with mkdirhow to have java create a folderjava create directory if not existhow to create folder in javahow to create a folder using javacreate directories if not exists javacreate new directory javahow to create folder in documents javacreate folder java springcreate directory with javacreate a folder if not exists in javacreate a folder from file javajava add file object to directoryjava create new directory filesjava make a folderwrite a java program to create a folder create new file directory javajava how to make a folderjava 8 create directory if not existsjava io create directory if not existshow to create directory path in javahow to assign to directory in javahow to make a directory javafcreate folder in javajava file create directory if not existscreate folders javahow to create folder in java if not existsjava create a new folderjava create new folder if not existcreating directory in javahow to create directory in javahow to create dir in javacreate new dir and file if not existsjava how to create a folderjava creating folders instead of fileshow to create directory in windows using javajava how to create directoriesjava how to create folders in pathmake directory using java java make new directorycreate a new folder javajava check if directory exists and createjava folder createjava folder does not existcreate a directory at path javacheck if directory exists javacreate folder and sub folder in javajava create folder if not existhow create directory javajava create folders if not existccreate directory in javacreate folder using javacheck if folder exists if not create javacreat folder in javahow to create a directory in java codejava create directory filehow to make a directory in javacreate a new directory javajava create folder from folder classhow to create a new directory in javahow to publish into particular directory in javajava create folderpython create json file if not existsfile directories in javahow to make a folder in javajava create directory in pathjava create directoryjava create new directory with a namecreate a new folder using javajava create dirscreate directory if not exists javacreate folder in javaspring boot create folder if not existscreate a folder javajava create directory in document foldercheck if directory exists and create javajava crate folderdirectory in javamaking a directory inside a directory javacreate a java folder from scratchhow to create directories in javajava create directory by pathcreate new folder in javajava windows how to make a directoryjava create dirif not existscreate directory if doesn 27t exist javajava create folder from string pathnew file in java is not create new directoryjava create new directory with name create directory for file javacreate folder path javamake a directory in java if not existjava program that creates a new foldercreate a directory in file class javacreate directory from java codehow to create a directory in javahow to write a directory in java from the classjava 8 create folder if not existsjava creates file as directoryjava creat foldercheck path exists java if not create create directories javacreate directory path javajava make directory if not existshow can create folder in java java bin folderjava create dirjava file object add file to directorymkdir if not exists javahow to make directory javajava code to create a directoryjava nio create directory if not existscreate a folder dynamically in javacreate a directory in javajava create all directories in pathcreate a directory if not exists in javacreate directory using java filehow to create a folder by javacreate java directorycreate folder javacreate file in local directory javahow to create folder with main javacreate dir javahow to create a directory using javamake new directory javafolder creation using javajava how to create directoryhow to make folders in javacreate folder if not exists and create new filejava create a foldercreate directory in java programmaticallyhow to make new folder in javanew directory in javahow to make new directory javacreate a folder from file javajava create fodlercreate directory java iocretae folder if not exists javahow to create folderrs in javahow to create folder javajava directory exists createcreate diretory if not exists in javacretedriecoryy in file class in javahow to create an out folder in javacreate folder in java if it doesnt existpath java create directorycreate folder java if not existshow to create folder inside java main method in javahow to make a new directory path in javawhat do we use to create folders in javajava create directory from pathhow to create a directoru in javajava path create directory if not existsjava nio create folder if not existsjava create directory in directoryjava how to create folder if not existcreate dir in javajava create directory if does not existhow to make a folder in java codemake folder javacrreate seprate folder in java filejava 8 create directoryjava file create directory if does not existcreate new folder javacreate ordner javamake new directory jacajava cant create folderjava make directoryhow to create folder using javacreated file object on directorycreatee a directory in javahow to create a folder using file javajava create file and foldersjava making a file directorycreate a directory javacreate directory if not present in javajava create directory windowsjava file create new folderjava how to create folderhow to create folders in javahow to make a folder using javajava folder create if not existjava method to make a directoryjava program to create a folderhow to create directory in java