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 .