Here you can find the source of saveFile(String path, Map
Parameter | Description |
---|---|
path | the path to save to including filename. |
setup | the setup of the settings. |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
public static void saveFile(String path, Map<String, Map<String, String>> setup) throws IOException
//package com.java2s; /*/* www . ja va 2 s . com*/ * Copyright (c) 2015 Zachary Rauen * Website: www.ZackRauen.com * * All rights reserved. Use is subject to license terms. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * If a copy of the License is not provided with the work, you may * obtain a copy at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Map; public class Main { /** * Save file of settings when given the correct format of settings. * * @param path the path to save to including filename. * @param setup the setup of the settings. * @throws IOException Signals that an I/O exception has occurred. */ public static void saveFile(String path, Map<String, Map<String, String>> setup) throws IOException { PrintWriter p = new PrintWriter(new FileWriter(path), true); for (String heading : setup.keySet()) { p.println("[" + heading + "]"); for (String key : setup.get(heading).keySet()) { p.println(key + "=" + setup.get(heading).get(key)); } p.println(""); } p.close(); } }