Java FileWriter Write saveMeasures(String appDirPath, String fileName, double[] measures)

Here you can find the source of saveMeasures(String appDirPath, String fileName, double[] measures)

Description

save Measures

License

Apache License

Declaration

public static void saveMeasures(String appDirPath, String fileName, double[] measures) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.BufferedWriter;
import java.io.File;

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

import java.io.PrintWriter;

public class Main {
    public static void saveMeasures(String appDirPath, String fileName, double[] measures) {
        String filePath = appDirPath + File.separator + fileName;
        PrintWriter pw = null;//from  w  w w .jav a2s.c  o m
        boolean autoFlush = true;
        try {
            pw = new PrintWriter(new BufferedWriter(new FileWriter(filePath)), autoFlush);
        } catch (IOException e) {
            e.printStackTrace();
            exit(1);
        }
        double RMSE = measures[0];
        double MAP = measures[1];
        double MRR = measures[2];
        double MP10 = measures[3];
        pw.printf("RMSE: %.8g\n", RMSE);
        pw.printf("MAP: %.8g\n", MAP);
        pw.printf("MRR: %.8g\n", MRR);
        pw.printf("MP@10: %.8g\n", MP10);
        pw.close();
    }

    public static void exit(int status) {
        System.exit(status);
    }
}

Related

  1. saveListStringToFile(String filePath, List listString)
  2. saveListToFile(ArrayList list, String filePath)
  3. saveMap(Map map, String filePath)
  4. saveMap(String filename, Map map)
  5. saveMappingFile(File mappingFile, Map messageMap)
  6. saveMetaClassToFile(File baseDir, String clazzDef, String metaPackageName, Class fromClazz)
  7. saveMetadata(Map metadata, File file)
  8. saveModelInFile(final String model, final String filename)
  9. savePValue2File(double[] pValue, String fileName)