@Override
    public void writeFile(String arg0, Map result) {

        // Initial variables
        HashMap culData;              // Data holder for one site of cultivar data
        ArrayList<HashMap> culArr;    // Data holder for one site of cultivar data
        BufferedWriter bwC;                             // output object
        StringBuilder sbData = new StringBuilder();     // construct the data info in the output

        try {

            // Set default value for missing data
            setDefVal();

            culData = getObjectOr(result, "dssat_cultivar_info", new HashMap());
            culArr = getObjectOr(culData, "data", new ArrayList());
            if (culArr.isEmpty()) {
                return;
            }
//            decompressData(culArr);

            // Initial BufferedWriter
            // Get File name
            String fileName = getFileName(result, "X");
            if (fileName.matches("TEMP\\d{4}\\.\\w{2}X")) {
                fileName = "Cultivar.CUL";
            } else {
                try {
                    fileName = fileName.replaceAll("\\.", "_") + ".CUL";
                } catch (Exception e) {
                    fileName = "Cultivar.CUL";
                }
            }
            arg0 = revisePath(arg0);
            outputFile = new File(arg0 + fileName);
            bwC = new BufferedWriter(new FileWriter(outputFile, outputFile.exists()));

            // Output Cultivar File
            String lastHeaderInfo = "";
            String lastTitles = "";
            for (HashMap culSubData : culArr) {
                // If come to new header, add header line and title line
                if (!getObjectOr(culSubData, "header_info", "").equals(lastHeaderInfo)) {
                    lastHeaderInfo = getObjectOr(culSubData, "header_info", "");
                    sbData.append(lastHeaderInfo).append("\r\n");
                    lastTitles = getObjectOr(culSubData, "cul_titles", "");
                    sbData.append(lastTitles).append("\r\n");
                }
                // If come to new title line, add title line
                if (!getObjectOr(culSubData, "cul_titles", "").equals(lastTitles)) {
                    lastTitles = getObjectOr(culSubData, "cul_titles", "");
                    sbData.append(lastTitles).append("\r\n");
                }
                // Write data line
                sbData.append(getObjectOr(culSubData, "cul_info", "")).append("\r\n");
            }

            // Output finish
            bwC.write(sbError.toString());
            bwC.write(sbData.toString());
            bwC.close();

        } catch (IOException e) {
            LOG.error(DssatCommonOutput.getStackTrace(e));
        }
    }
@ Override public void writeFile ( String arg0 , Map result ) { HashMap culData ; ArrayList < HashMap > culArr ; BufferedWriter bwC ; StringBuilder sbData = new StringBuilder ( ) ; try { setDefVal ( ) ; culData = getObjectOr ( result , "dssat_cultivar_info" , new HashMap ( ) ) ; culArr = getObjectOr ( culData , "data" , new ArrayList ( ) ) ; if ( culArr . isEmpty ( ) ) { return ; } String fileName = getFileName ( result , "X" ) ; if ( fileName . matches ( "TEMP\\d{4}\\.\\w{2}X" ) ) { fileName = "Cultivar.CUL" ; } else { try { fileName = fileName . replaceAll ( "\\." , "_" ) + ".CUL" ; } catch ( Exception e ) { fileName = "Cultivar.CUL" ; } } arg0 = revisePath ( arg0 ) ; outputFile = new File ( arg0 + fileName ) ; bwC = new BufferedWriter ( new FileWriter ( outputFile , outputFile . exists ( ) ) ) ; String lastHeaderInfo = "" ; String lastTitles = "" ; for ( HashMap culSubData : culArr ) { if ( ! getObjectOr ( culSubData , "header_info" , "" ) . equals ( lastHeaderInfo ) ) { lastHeaderInfo = getObjectOr ( culSubData , "header_info" , "" ) ; sbData . append ( lastHeaderInfo ) . append ( "\r\n" ) ; lastTitles = getObjectOr ( culSubData , "cul_titles" , "" ) ; sbData . append ( lastTitles ) . append ( "\r\n" ) ; } if ( ! getObjectOr ( culSubData , "cul_titles" , "" ) . equals ( lastTitles ) ) { lastTitles = getObjectOr ( culSubData , "cul_titles" , "" ) ; sbData . append ( lastTitles ) . append ( "\r\n" ) ; } sbData . append ( getObjectOr ( culSubData , "cul_info" , "" ) ) . append ( "\r\n" ) ; } bwC . write ( sbError . toString ( ) ) ; bwC . write ( sbData . toString ( ) ) ; bwC . close ( ) ; } catch ( IOException e ) { LOG . error ( DssatCommonOutput . getStackTrace ( e ) ) ; } }
DSSAT Cultivar Data Output method

@param arg0 file output path
@param result data holder object