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

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

Description

create a new file and save the doubleArray to the fileName

License

Open Source License

Declaration

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

Method Source Code


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

import java.io.*;

public class Main {
    /**//from  w  w w.  j  av a 2  s . c  o m
     * create a new file and save the doubleArray to the fileName
     */
    public static void saveDoubleArray2File(Double[] doubleArray, String fileName) throws IOException {
        FileWriter fw = null;
        fw = new FileWriter(fileName);
        String str = "";
        for (int i = 0; i < doubleArray.length; i++) {
            str = str + doubleArray[i];
            str = str + "\n";
        }
        fw.write(str);
        fw.close();
    }

    /**
     * save double array ; if there is no file, it creates this fileName,
     * otherwise it will override this file
     */
    public static void savedoubleArray2File(double[] abnormalNodes, String fileName) throws IOException {
        FileWriter fw = null;
        fw = new FileWriter(fileName, false);
        String str = "";
        for (int i = 0; i < abnormalNodes.length; i++) {
            str = str + abnormalNodes[i];
            str = str + "\n";
        }
        fw.write(str);
        fw.close();
    }
}

Related

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