private List < String > getFieldListFromHeader ( BufferedReader reader ) { // Read the first line and watch out for BOM at the front of the header. String header = null ; try { header = reader . readLine ( ) ; } catch ( IOException e ) { // Leave header null } if ( Utils . isEmpty ( header ) ) { logErrorThrow ( "No header found in file" ) ; } if ( header . charAt ( 0 ) == ' ' ) { header = header . substring ( 1 ) ; } // Split around commas, though this will include spaces. String [ ] tokens = header . split ( "," ) ; List < String > result = new ArrayList < String > ( ) ; for ( String token : tokens ) { // If this field matches the _ID field, add it with that name. String fieldName = token . trim ( ) ; if ( fieldName . equals ( m_config . id ) ) { result . add ( CommonDefs . ID_FIELD ) ; } else { result . add ( token . trim ( ) ) ; } } return result ; }
Extract the field names from the given CSV header line and return as a list .