Here you can find the source of saveProperties(Properties props, File location)
Parameter | Description |
---|---|
props | The properties object to save. |
location | The location to save the properties to. |
Parameter | Description |
---|---|
IOException | If the file is not writable |
public static void saveProperties(Properties props, File location) throws IOException
//package com.java2s; import java.io.*; import java.util.*; public class Main { /**/* ww w. j av a 2s.com*/ * Save a {@link Properties} object to a path. * @param props The properties object to save. * @param location The location to save the properties to. * @throws IOException If the file is not writable */ public static void saveProperties(Properties props, File location) throws IOException { PrintStream os = new PrintStream(new FileOutputStream(location.getAbsolutePath())); List<String> keys = new ArrayList<>(props.stringPropertyNames()); Collections.sort(keys); for (Object key : keys) { os.println(key.toString() + " = " + props.get(key).toString()); } os.close(); } }