Here you can find the source of saveProperties(Properties properties, File propertiesFile, String comments)
.properties
file
Parameter | Description |
---|---|
properties | Properties with data to save |
propertiesFile | File of the <code>.properties</code> file to save |
comments | Some description to be located as comment at the beginning of the content of the file |
Parameter | Description |
---|---|
IOException | Error while writing the file |
public static void saveProperties(Properties properties, File propertiesFile, String comments) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Properties; public class Main { /**//from ww w. j a va 2s. c om * Save data from a Properties object into some <code>.properties</code> file * * @param properties {@link Properties} with data to save * @param propertiesFile {@link File} of the <code>.properties</code> file to save * @param comments Some description to be located as comment at the beginning of the * content of the file * @throws IOException Error while writing the file */ public static void saveProperties(Properties properties, File propertiesFile, String comments) throws IOException { if (!(propertiesFile.exists() && propertiesFile.isFile())) { propertiesFile.createNewFile(); } try (OutputStream out = new FileOutputStream(propertiesFile)) { properties.store(out, comments); } } }