private void storeToCsvFile(File file) {
            if(decodedData.size() > 0) {
                UARTProtocolAnalysisDataSet dSet;
                System.out.println("writing decoded data to " + file.getPath());
                try {
                    BufferedWriter bw = new BufferedWriter(new FileWriter(file));

                    bw.write("\"" + 
                             "index" + 
                             "\",\"" +
                             "time" +
                             "\",\"" +
                             "RxD data or event" +
                             "\",\"" +
                             "TxD data or event" +
                             "\"");
                    bw.newLine();

                    for(int i = 0; i < decodedData.size(); i++) {
                        dSet = decodedData.get(i);
                        switch(dSet.type) {
                        case UARTProtocolAnalysisDataSet.UART_TYPE_EVENT:
                            bw.write("\"" + 
                                     i + 
                                     "\",\"" +
                                     indexToTime(dSet.time) +
                                     "\",\"" +
                                     dSet.event +
                                     "\",\"" +
                                     dSet.event +
                                     "\"");
                            break;
                        case UARTProtocolAnalysisDataSet.UART_TYPE_RXEVENT:
                            bw.write("\"" + 
                                     i + 
                                     "\",\"" +
                                     indexToTime(dSet.time) +
                                     "\",\"" +
                                     dSet.event +
                                     "\",\"" +
                                     "\"");
                            break;
                        case UARTProtocolAnalysisDataSet.UART_TYPE_TXEVENT:
                            bw.write("\"" + 
                                     i + 
                                     "\",\"" +
                                     indexToTime(dSet.time) +
                                     "\",\"" +
                                     "\",\"" +
                                     dSet.event +
                                     "\"");
                            break;
                        case UARTProtocolAnalysisDataSet.UART_TYPE_RXDATA:
                            bw.write("\"" + 
                                     i + 
                                     "\",\"" +
                                     indexToTime(dSet.time) +
                                     "\",\"" +
                                     dSet.data +
                                     "\",\"" +
                                     "\"");
                            break;
                        case UARTProtocolAnalysisDataSet.UART_TYPE_TXDATA:
                            bw.write("\"" + 
                                     i + 
                                     "\",\"" +
                                     indexToTime(dSet.time) +
                                     "\",\"" +
                                     "\",\"" +
                                     dSet.data +
                                     "\"");
                            break;
                        default:
                            break;
                        }
                        bw.newLine();
                    }
                    bw.close();
                } catch (Exception E) {
                    E.printStackTrace(System.out);
                }
            }
        }