public static void writeCSVRows ( XYSeries series , String path2Dir ) { File newFile = new File ( path2Dir + series . getName ( ) + ".csv" ) ; Writer out = null ; try { out = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( newFile ) , "UTF8" ) ) ; String csv = join ( series . getXData ( ) , "," ) + System . getProperty ( "line.separator" ) ; out . write ( csv ) ; csv = join ( series . getYData ( ) , "," ) + System . getProperty ( "line.separator" ) ; out . write ( csv ) ; if ( series . getExtraValues ( ) != null ) { csv = join ( series . getExtraValues ( ) , "," ) + System . getProperty ( "line.separator" ) ; out . write ( csv ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( out != null ) { try { out . flush ( ) ; out . close ( ) ; } catch ( IOException e ) { // NOP } } } }
Export a XYChart series into rows in a CSV file .