groovy默认在哪里查找属性文件?

时间:2016-04-04 07:18:14

标签: netbeans groovy configuration properties-file idioms

对于这个Netbeans项目:

.
├── build.xml
├── manifest.mf
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── groovy-build.xml
│   ├── private
│   │   └── private.properties
│   ├── project.properties
│   └── project.xml
└── src
    ├── Config1.groovy
    └── net
        └── bounceme
            └── mordor
                └── groovy
                    └── file_ops
                        └── NewGroovyScript.groovy

8 directories, 10 files

foo.properties的标准位置或路径是什么,以便它can be easily picked up?在src

1 个答案:

答案 0 :(得分:1)

您应该能够将其与NewGroovyScript.groovy类文件放在同一个文件夹中,然后执行:

Properties p = NewGroovyScript.class.getResource('foo.properties').withInputStream { s ->
    Properties properties = new Properties()
    properties.load(s)
    properties
}