Skip to content

Instantly share code, notes, and snippets.

@hayasshi
Last active August 29, 2015 13:56
Show Gist options
  • Save hayasshi/6edddeee838a44beba27 to your computer and use it in GitHub Desktop.
Save hayasshi/6edddeee838a44beba27 to your computer and use it in GitHub Desktop.
Object Resource {
// 実行時例外
val prop1 = new Properties
prop1.load(new FileInputStream("config.properties")) // -> FileNotFoundExceptionが投げられる
// target/scala-ver/classes/config.propertiesが読み込まれる
// (コンパイル前: src/main/resources/config.properties)
val prop2 = new Properties
prop2.load(this.getClass().getClassLoader().getResourceAsStream("config.properties")) // -> 読み込む
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment