Java BufferedWriter Write writeFile(String outputLocation, String fileName, List content)

Here you can find the source of writeFile(String outputLocation, String fileName, List content)

Description

write File

License

Open Source License

Declaration

public static void writeFile(String outputLocation, String fileName, List<String> content) 

Method Source Code

//package com.java2s;
/**/*from   www.  ja v a  2 s. co  m*/
 * Copyright (c) {2011} {meter@rbtsb.com} {
 * individual contributors as indicated by the @authors tag}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Private License v1.0
 * which accompanies this distribution, and is available at
 * http://www.rbtsb.com
 */

import java.io.BufferedWriter;

import java.io.File;

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

import java.util.List;

public class Main {
    public static void writeFile(String outputLocation, String fileName, List<String> content) {
        try {
            boolean addLine = true;
            if (!(new File(outputLocation.concat(fileName)).exists())) {
                addLine = false;
            }
            FileWriter fw = new FileWriter(outputLocation.concat(fileName), true);
            BufferedWriter bw = new BufferedWriter(fw);
            int count = 0;
            if (addLine) {
                bw.newLine();
            }
            //Append files at new Line.
            for (String c : content) {
                count++;
                bw.write(c);
                if (content.size() == count) {
                } else {
                    bw.newLine();
                }
            }
            bw.close();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(String file, List data)
  2. writeFile(String filename, ArrayList entries)
  3. writeFile(String filename, Map map)
  4. writeFile(String line, File file)
  5. writefile(String m, String path)
  6. writeFile(String p_name, String p_encoding, String p_content)
  7. writeFileAppend(String filePath, String content)
  8. writeFileContent(File audioFile, short[] data, boolean littleEndian)
  9. writeFileContents(File file, String contents)