Created
June 8, 2013 11:05
-
-
Save tomoyamkung/5734838 to your computer and use it in GitHub Desktop.
[Java]サーブレットでクラスパス上にあるプロパティファイルを参照するスニペット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void doGet(HttpServletRequest request, | |
HttpServletResponse response) throws ServletException, IOException { | |
ClassLoader classLoader = this.getClass().getClassLoader(); | |
InputStream inputStream = classLoader.getResourceAsStream("app.properties"); | |
Properties properties = new Properties(); | |
properties.load(inputStream); | |
String hoge = properties.getProperty("hoge"); | |
response.getWriter().print(hoge); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment