fileinputstream - Can we write data to a config.properties file using FileWriter and BufferedWrirter combination in a key value pair format -


using filewriter, can write key value pair username = "login_data" .properties file instead of .txt file?

string value1 = "this value file writer";  system.out.println("key1 == " + value1);  filewriter fw = new filewriter(datafilepath, true); bufferedwriter bw = new bufferedwriter(fw);  bw.write(value1); bw.close(); 

to store properties better create properties object, put values , save via store() method.

if want keep layout , comments too, it's worth looking @ apache commons propertiesconfigurationlayout:

propertiesconfiguration config = new propertiesconfiguration(); propertiesconfigurationlayout layout = new propertiesconfigurationlayout();  config.setproperty("key", "value"); layout.setcomment("key", "description of key");  layout.setheadercomment("file description");  layout.save(config, new filewriter (file)); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -