這些屬性讓我瘋狂。我到處讀書,甚至加載的屬性應該沒有問題,只是使用:屬性讓我瘋狂。無法保存! 「FileNotFound」
Properties p = new Properties();
p.load(new FileInputStream("filename.properties");
雖然在我的情況下,它的工作。 Java沒有找到該文件,它位於類目錄中!這就是爲什麼我必須與Assetmanager一起使用它:
String defaultProfileProperties = "filename.properties";
Resources resources = this.getResources();
AssetManager assetManager = resources.getAssets();
final Properties properties = new Properties();
try {
InputStream inputStream = assetManager.open(defaultProfileProperties);
properties.load(inputStream);
} catch (IOException e) {
System.err.println("Failed to open " + defaultProfileProperties + " property file");
e.printStackTrace();
}
將文件名.properties放在資產文件夾中。 (out,comment)... 我嘗試使用FileOutputStream,將路徑設置爲「filename.properties」或「assets」 /filename.properties」。他們都沒有工作。我甚至在這裏和那裏添加了斜線,但沒有任何幫助!我沒有在網上找到任何教程,也沒有發現同樣的問題!
你能幫我嗎?我猜這是如此簡單的事情,但我不知道如何......等等