次のようなプロパティを定義するコードがあります。
public static final String DEFINED_KEY = "definedKey";
public static final String DEFINED_PROPERTY = "definedProperty";
// [...]
File f = File.createTempFile("default", ".properties");
PrintWriter pw = new PrintWriter(f);
Properties pp = new Properties();
pp.setProperty(DEFINED_KEY, DEFINED_PROPERTY);
pp.store(pw, "Automatically defined");
pw.close();
プロパティファイルを保存する
#No comments
#Mon Feb 13 17:25:12 CET 2012
definedKey=definedProperty
別のプロパティを作成して実行するload()
と、正常に読み込まれます。get(DEFINED_KEY)
に指定された値を返しますDEFINED_PROPERTY
が、をgetProperty(DEFINED_KEY)
返しますnull
。これどうしたの?