public static String [ ] removeEmpties ( final String ... values ) { if ( values == null || values . length == 0 ) { return new String [ 0 ] ; } List < String > validValues = new ArrayList < String > ( ) ; for ( String value : values ) { if ( value != null && value . length ( ) > 0 ) { validValues . add ( value ) ; } } return validValues . toArray ( new String [ validValues . size ( ) ] ) ; }
Create an array with only the non - null and non - empty values