Java Properties Save saveProperties(Properties p, String file)

Here you can find the source of saveProperties(Properties p, String file)

Description

save Properties

License

Open Source License

Declaration

public static void saveProperties(Properties p, String file) 

Method Source Code


//package com.java2s;
/*//  w  w  w  .j  ava  2s.  c om
 *   Copyright 2010 Nick Powers.
 *   This file is part of WSExplorer.
 *
 *   WSExplorer 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.
 *
 *   WSExplorer 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 WSExplorer.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.util.Properties;

public class Main {
    public static void saveProperties(Properties p, String file) {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(new File(file));
            p.store(fos, "User saved");
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (fos != null) {
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
                // ignore
            }
        }
    }
}

Related

  1. saveParamToFile(String fileName, String param, String value)
  2. saveProperties()
  3. saveProperties(final IResource modelResource, final Properties props)
  4. saveProperties(Map map, File file, String encoding)
  5. saveProperties(Map map, Writer tmpWriter)
  6. saveProperties(Properties p, String sFile)
  7. saveProperties(Properties prop, String fileName, String remark)
  8. saveProperties(Properties properties, File file)
  9. saveProperties(Properties properties, File propertiesFile, String comments)