public static Array listToArrayTrim ( String list , char delimiter ) { if ( list . length ( ) == 0 ) return new ArrayImpl ( ) ; // remove at start while ( list . indexOf ( delimiter ) == 0 ) { list = list . substring ( 1 ) ; } int len = list . length ( ) ; if ( len == 0 ) return new ArrayImpl ( ) ; while ( list . lastIndexOf ( delimiter ) == len - 1 ) { list = list . substring ( 0 , len - 1 < 0 ? 0 : len - 1 ) ; len = list . length ( ) ; } return listToArray ( list , delimiter ) ; }
casts a list to Array object remove all empty items at start and end of the list