Accueil‎ > ‎

Java - Read/Write Properties files

posted 21 Sep 2018, 02:29 by Christophe Noël
The properties files (e.g. config.properties) should be located in src/main/resources.

You write using:
Properties prop = new Properties();
OutputStream  output = new FileOutputStream("config.properties");
prop.setProperty("database", "localhost");
prop.store(output, "comments");
You write using:
Properties prop = new Properties();
InputStream input = new FileInputStream("config.properties");
prop.load(input);
prop.getProperty("database")
Comments