Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
Created June 8, 2013 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyamkung/5734838 to your computer and use it in GitHub Desktop.
Save tomoyamkung/5734838 to your computer and use it in GitHub Desktop.
[Java]サーブレットでクラスパス上にあるプロパティファイルを参照するスニペット
@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