Here you can find the source of storePropertiesFile(String fileName, String filePath, String storeComment)
public static void storePropertiesFile(String fileName, String filePath, String storeComment)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.net.URL; import java.util.Properties; public class Main { private static Properties properties = new Properties(); public static void storePropertiesFile(String fileName, String filePath, String storeComment) { if (fileName == null || "".equals(fileName.trim())) { throw new RuntimeException("File name is null"); } else {/*w w w . j a va 2s . co m*/ fileName = fileName.trim(); if (!fileName.toLowerCase().endsWith(".properties")) { fileName += ".properties"; } } File propertiesFile = null; OutputStream out; try { if (filePath == null || "".equals(filePath.trim())) { filePath = Thread.currentThread().getContextClassLoader().getResource("").toString() + fileName; propertiesFile = new File(new URL(filePath).toURI()); } else { filePath = filePath.trim(); if (!filePath.endsWith("/") && !filePath.endsWith("\\")) { filePath += "/"; } filePath += fileName; propertiesFile = new File(filePath); } out = new FileOutputStream(propertiesFile); properties.store(out, storeComment); out.close(); } catch (Exception e) { e.printStackTrace(); } } }