@ SneakyThrows public static List < String > split ( CharSequence input , char separator ) { if ( input == null ) { return new ArrayList <> ( ) ; } Preconditions . checkArgument ( separator != ' ' , "Separator cannot be a quote" ) ; try ( CSVReader reader = CSV . builder ( ) . delimiter ( separator ) . reader ( new StringReader ( input . toString ( ) ) ) ) { List < String > all = new ArrayList <> ( ) ; List < String > row ; while ( ( row = reader . nextRow ( ) ) != null ) { all . addAll ( row ) ; } return all ; } }
Properly splits a delimited separated string .