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
Post a Comment