Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public static void printToFile(String resultsFileName, String fileName, String studyType, String relTol, double maxResult, double Wint, double Qint, double nteFlux, double dEi0Int) {
    //Print data to file
    try {
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(resultsFileName, true)));
        out.print(studyType + "," + relTol + "," + maxResult + "," + Wint + "," + Qint + "," + nteFlux + "," + dEi0Int + ",");
        
        boolean error = false;

        try {
            if (maxResult > Double.parseDouble(relTol)) {
                out.print("true");
                error = true;
            } else if (relTol.equals("NaN")) {
                out.print("!!!!!! Undefined relative tolerance, check the results.");
            }
        } catch (Exception e) {
            out.print("!!!!!! Undefined relative tolerance, check the results.");
        }

        out.println();

        out.close();
    } catch (IOException e) {
        //JOptionPane.showMessageDialog(null, "There was a problem while writing to result file.");
    }
}