public static String [ ] removeEmptyStrings ( String [ ] strings ) { if ( Objects . isNull ( strings ) ) { throw new IllegalArgumentException ( "Input array should not be null" ) ; } return Arrays . stream ( strings ) . filter ( str -> str != null && ! str . trim ( ) . isEmpty ( ) ) . toArray ( String [ ] :: new ) ; }
Remove empty Strings from string array