Java PrintWriter Write save(Map map, String fileName)

Here you can find the source of save(Map map, String fileName)

Description

save

License

Open Source License

Parameter

Parameter Description
map a parameter
fileName a parameter

Declaration

public static void save(Map<String, String> map, String fileName) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2012 by Min Cai (min.cai.china@gmail.com).
 *
 * This file is part of the PickaPack library.
 *
 * PickaPack is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.//from   www . j  a  v  a 2 s  .co  m
 *
 * PickaPack is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PickaPack. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

import java.io.*;
import java.util.Map;

public class Main {
    /**
     *
     * @param map
     * @param fileName
     */
    public static void save(Map<String, String> map, String fileName) {
        try {
            save(map, new FileOutputStream(fileName));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     *
     * @param map
     * @param out
     */
    public static void save(Map<String, String> map, OutputStream out) {
        if (map.size() > 0) {
            PrintWriter pw = new PrintWriter(out);

            for (Map.Entry<String, String> entry : map.entrySet()) {
                pw.println(entry.getKey() + "=" + entry.getValue());
            }

            pw.close();
        }
    }
}

Related

  1. save(final Multimap map, final Writer target, final String sep)
  2. save(String fileName, List list)
  3. save(String s, File file)
  4. saveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
  5. saveConvert(final String text, final int escapeMode, final PrintWriter writer)