2004-10-18から1日間の記事一覧

submap()

Mapから、指定したプリフィックスのキーと値を取得する。 プロパティファイルでマッピングの定義をするときとかに使う。 private static Map submap(Map map, String prefix, boolean hasPrefix) { Map submap = new HashMap(); Iterator keys = map.keySet(…

クラスパスから設定ファイル読み込み

どんなアプリでもたいてい使うので。 staticな場合は「this→クラス名.class」。 private Properties load(String filename) throws IOException { Properties props = new Properties(); InputStream in = null; try { ClassLoader cloader = Thread.current…