Here you can find the source of appendFileLines(String fileName, String[] data)
Parameter | Description |
---|---|
f | non-null of file to create |
data | non-null array of lines to write |
public static boolean appendFileLines(String fileName, String[] data)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**// w ww . ja v a2 s .c o m * { method * * @param f non-null of file to create * @param data non-null array of lines to write * @return true = success * } * @name appendFileLines * @function append the string data to the file Filename */ public static boolean appendFileLines(String fileName, String[] data) { return appendFileLines(new File(fileName), data); } /** * { method * * @param f non-null of file to create * @param data non-null array of lines to write * @return true = success * } * @name writeFileLines * @function write the string data to the file Filename */ public static boolean appendFileLines(File f, String[] data) { try { PrintWriter out = openAppendPrintWriter(f); if (out != null) { for (int i = 0; i < data.length; i++) out.println(data[i]); out.close(); return (true); } return (false); // failure } catch (SecurityException ex) { return (false); // browser disallows } } /** * { method * * @param name name of file * @return the stream - null for failure * } * @name openPrintWriter * @function open a PrintWriter to a file with name */ public static PrintWriter openAppendPrintWriter(File name) { FileOutputStream file = null; try { file = new FileOutputStream(name, true); return new PrintWriter(new BufferedOutputStream(file)); } catch (SecurityException ee) { return (null); } catch (IOException ee) { return (null); } } }