我正在尝试在文件夹web-app中创建新文件夹,我想在run-app上创建。怎么做?
答案 0 :(得分:0)
正如您已经说过的那样,它应该在run-app上创建,然后应该放在bootstrap.groovy
文件中。
Boolean exists ( ) -returns true if the file or directory exists
Boolean mkdir ( ) - creates a directory if it doesn't exist.
String getPath ( ) - returns String with the full pathname.
使用上述内容:
def createDir(dirName) {
String final static dirpath = '/web-app/'+dirname
File pathDir = new File(dirpath).mkdirs()
if (pathDir.exists()){
println("Directory$dirpath created");
}else{
println(" Failed to create Directory$dirpath / directory already exists !");
}
}
ALLOHA!