In File class , there is a method , mkdir() , which can be used to create directory.
The example is as below:
boolean success = (new File("directoryName")).mkdir();
if (!success)
{
System.out.println("Directory create failed!!");
}
In File class , it also has another method , mkdirs() , we can use this method if we want to create hierarchical directory .
for example:
This example will create two directory , one is datasets directory , and the other is class_2 directory.
String classNum = "datasets\\class_"+2;
boolean success = (new File(classNum)).mkdirs();
if(!success)
{
System.out.println("directory is created failed...");
}
文章標籤
全站熱搜
