Java FileWriter Write saveDoubleArray2FileAppend(Double[] doubleArray, String fileName)

Here you can find the source of saveDoubleArray2FileAppend(Double[] doubleArray, String fileName)

Description

save doubleArray to fileName, if the file exists, we just append the double array to the file

License

Open Source License

Declaration

public static void saveDoubleArray2FileAppend(Double[] doubleArray, String fileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    /**/* w w  w . j a v a  2s .co m*/
     * save doubleArray to fileName, if the file exists, we just append the
     * double array to the file
     */
    public static void saveDoubleArray2FileAppend(Double[] doubleArray, String fileName) throws IOException {
        FileWriter fw = null;
        fw = new FileWriter(fileName, true);
        String str = "";
        for (int i = 0; i < doubleArray.length; i++) {
            str = str + doubleArray[i];
            str = str + "\n";
        }
        fw.write(str);
        fw.close();
    }

    /**
     * save doubleArray to fileName, if the file exists, we just append this
     * array to the fileName
     */
    public static void savedoubleArray2FileAppend(double[] doubleArray, String fileName) throws IOException {
        FileWriter fw = null;
        fw = new FileWriter(fileName, true);
        String str = "";
        for (int i = 0; i < doubleArray.length; i++) {
            str = str + doubleArray[i];
            str = str + "\n";
        }
        fw.write(str);
        fw.close();
    }

    /**
     * @param flag
     *            can control append the array to the fileName or not
     */
    public static void savedoubleArray2FileAppend(double[] doubleArray, String fileName, boolean flag)
            throws IOException {
        FileWriter fw = null;
        fw = new FileWriter(fileName, flag);
        String str = "";
        for (int i = 0; i < doubleArray.length; i++) {
            str = str + doubleArray[i];
            str = str + "\n";
        }
        fw.write(str);
        fw.close();
    }
}

Related

  1. saveData(Map> data, String file)
  2. saveData(String fileName, double totalTime, int[] resultSubset)
  3. saveDictionary(String fileName, Map values)
  4. saveDotGraph(final String dotGraph, final File outputDirectory)
  5. saveDoubleArray2File(Double[] doubleArray, String fileName)
  6. saveEasyQuestImpl(final String quest, final File targetFile)
  7. saveFile(File directory, String fileName, String content)
  8. saveFile(File file, String contents)
  9. saveFile(File file, String data)