Java FileWriter Write saveFile(String path, String sb)

Here you can find the source of saveFile(String path, String sb)

Description

save File

License

Open Source License

Declaration

public static void saveFile(String path, String sb) 

Method Source Code

//package com.java2s;
/**/*from  w ww  . j a  v a  2s .  co m*/
 * Copyright (c) 2011-2013 Armin T?pfer
 *
 * This file is part of InDelFixer.
 *
 * InDelFixer 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 any later version.
 *
 * InDelFixer 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
 * InDelFixer. If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.*;

public class Main {
    public static void saveFile(String path, String sb) {
        try {
            // Create file
            FileWriter fstream = new FileWriter(path);
            try (BufferedWriter out = new BufferedWriter(fstream)) {
                out.write(sb);
            }
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error save file: ");
            System.err.println(path);
        }
    }
}

Related

  1. saveFile(String filePath, String content)
  2. saveFile(String filePath, String data)
  3. saveFile(String path, Map> setup)
  4. saveFile(String path, String content)
  5. SaveFile(String path, String data, boolean deleteOnExit)
  6. saveFile(String[] lines, String savedName, String extension)
  7. saveFileContents(File file, String contents)
  8. saveFileFromString(File file, String encoding, String content)
  9. saveFiles(final List contents, final File outputDirectory, final String outputName, final String fileExtension)