문제

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