Java FileWriter Write saveFiles(final List contents, final File outputDirectory, final String outputName, final String fileExtension)

Here you can find the source of saveFiles(final List contents, final File outputDirectory, final String outputName, final String fileExtension)

Description

Save file contents in an output directory.

License

Open Source License

Parameter

Parameter Description
contents a parameter
outputDirectory a parameter
dirName a parameter
fileExtension a parameter

Exception

Parameter Description
IOException an exception

Declaration

private static void saveFiles(final List<String> contents, final File outputDirectory, final String outputName,
        final String fileExtension) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   w  w  w.j a v  a 2  s. c  om*/
 * Copyright 2012 jccastrejon
 *  
 * This file is part of ExSchema.
 *
 * ExSchema 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.
 *
 * ExSchema 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 ExSchema. If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import java.util.List;

public class Main {
    /**
     * Save file contents in an output directory.
     * 
     * @param contents
     * @param outputDirectory
     * @param dirName
     * @param fileExtension
     * @throws IOException
     */
    private static void saveFiles(final List<String> contents, final File outputDirectory, final String outputName,
            final String fileExtension) throws IOException {
        int index;
        File directory;
        File rooScriptFile;
        FileWriter fileWriter;

        // Save scripts in a new folder
        directory = new File(outputDirectory, outputName);
        directory.mkdir();

        index = 0;
        for (String content : contents) {
            index = index + 1;
            rooScriptFile = new File(directory, "schema" + index + "." + fileExtension);
            fileWriter = new FileWriter(rooScriptFile, false);
            fileWriter.write(content);
            fileWriter.close();
        }
    }
}

Related

  1. SaveFile(String path, String data, boolean deleteOnExit)
  2. saveFile(String path, String sb)
  3. saveFile(String[] lines, String savedName, String extension)
  4. saveFileContents(File file, String contents)
  5. saveFileFromString(File file, String encoding, String content)
  6. saveFlows(Map differences, String file)
  7. saveFormedClustersToFile(Vector names, Collection> clusters, String filename)
  8. saveGraph(List> graph, String sFileName)
  9. saveIndex(File root_, Hashtable index)