I know how to create a new folder, but i don't know how to way to create an another new folder into a new folder i just created

String y="C:/TEMP/Four Area";
File file=new File(y);
if(file.mkdir()){
    System.out.println("file is created");
}else{
    System.out.println("file is created");
}

But what i want is "C://TEMP/Four Area/New Area", i want system to create "New Area" folder into "Four Area" folder in above code. I tried to use String y="C://TEMP/Four Area/New Area, it won't create any folder

有帮助吗?

解决方案

use file.mkdirs() instead to create multiple nested directories

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top