如何在Grails的bootstrap中在web-app中创建新文件夹?

时间:2014-06-24 08:48:57

标签: grails

我正在尝试在文件夹web-app中创建新文件夹,我想在run-app上创建。怎么做?

1 个答案:

答案 0 :(得分:0)

正如您已经说过的那样,它应该在run-app上创建,然后应该放在bootstrap.groovy文件中。

Using groovy I/O operation

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!