private List<Instrument> readCSV(String input) throws IOException {
        ICsvBeanReader beanReader = null;
        File temp = File.createTempFile("tempfile", ".tmp");
        BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
        bw.write(input);
        bw.close();

        beanReader = new CsvBeanReader(new FileReader(temp), CsvPreference.STANDARD_PREFERENCE);
        String[] header = beanReader.getHeader(true);
        CellProcessor[] processors = getProcessors();
        Instrument instrument;
        List<Instrument> instruments = new ArrayList<>();
        while((instrument = beanReader.read(Instrument.class, header, processors)) != null ) {
            instruments.add(instrument);
        }
        return instruments;
    }
private List < Instrument > readCSV ( String input ) throws IOException { ICsvBeanReader beanReader = null ; File temp = File . createTempFile ( "tempfile" , ".tmp" ) ; BufferedWriter bw = new BufferedWriter ( new FileWriter ( temp ) ) ; bw . write ( input ) ; bw . close ( ) ; beanReader = new CsvBeanReader ( new FileReader ( temp ) , CsvPreference . STANDARD_PREFERENCE ) ; String [ ] header = beanReader . getHeader ( true ) ; CellProcessor [ ] processors = getProcessors ( ) ; Instrument instrument ; List < Instrument > instruments = new ArrayList < > ( ) ; while ( ( instrument = beanReader . read ( Instrument . class , header , processors ) ) != null ) { instruments . add ( instrument ) ; } return instruments ; }
This method parses csv and returns instrument list.
@param input is csv string.
@return  returns list of instruments.
@throws IOException is thrown when there is connection related error.