Here you can find the source of writeFile(String outputLocation, String fileName, List
public static void writeFile(String outputLocation, String fileName, List<String> content)
//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(); } } }