クラスHashMap
を使用してデータを入力したい。ファイル
にエントリをロードしてから、 .Properties
.propeties
HashMap
以前はHashMap
、プロパティ ファイルを使用して を初期化するだけでしたが、現在は既に を定義してHashMap
おり、コンストラクターのみで初期化したいと考えています。
以前のアプローチ:
Properties properties = new Properties();
try {
properties.load(ClassName.class.getResourceAsStream("resume.properties"));
} catch (Exception e) {
}
HashMap<String, String> mymap= new HashMap<String, String>((Map) properties);
しかし、今、私はこれを持っています
public class ClassName {
HashMap<String,Integer> mymap = new HashMap<String, Integer>();
public ClassName(){
Properties properties = new Properties();
try {
properties.load(ClassName.class.getResourceAsStream("resume.properties"));
} catch (Exception e) {
}
mymap = properties;
//The above line gives error
}
}
プロパティ オブジェクトをここに割り当てるにはどうすればよいHashMap
ですか?