javaでpropertiesファイルを読み込んで設定値を取得したいです。
java
1 private String getInfo(String key) { 2 String str = null; 3 try { 4 InputStream inputStream = new FileInputStream(new File("test.properties")); 5 Properties configuration = new Properties(); 6 configuration.load(inputStream); 7 8 str = configuration.getProperty(key); 9 10 } catch (IOException e) { 11 e.printStackTrace(); 12 } 13 return str; 14 }
javaは今回初めてなのでサイトを見ながらコードを書きました。
test.propertiesはWEB-INF直下です。
このコード自体間違っているのでしょうか。

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/14 19:20
2017/01/15 01:56