public static Array listToArrayTrim(String list,String delimiter){
  if (delimiter.length() == 1)   return listToArrayTrim(list,delimiter.charAt(0));
  if (list.length() == 0)   return new ArrayImpl();
  char[] del=delimiter.toCharArray();
  char c;
  outer:   while (list.length() > 0) {
    c=list.charAt(0);
    for (int i=0; i < del.length; i++) {
      if (c == del[i]) {
        list=list.substring(1);
        continue outer;
      }
    }
    break;
  }
  int len;
  outer:   while (list.length() > 0) {
    c=list.charAt(list.length() - 1);
    for (int i=0; i < del.length; i++) {
      if (c == del[i]) {
        len=list.length();
        list=list.substring(0,len - 1 < 0 ? 0 : len - 1);
        continue outer;
      }
    }
    break;
  }
  return listToArray(list,delimiter);
}

public static Array listToArrayTrim ( String list , String delimiter ) { if ( delimiter . length ( ) == 1 ) return listToArrayTrim ( list , delimiter . charAt ( 0 ) ) ; if ( list . length ( ) == 0 ) return new ArrayImpl ( ) ; char [ ] del = delimiter . toCharArray ( ) ; char c ; outer : while ( list . length ( ) > 0 ) { c = list . charAt ( 0 ) ; for ( int i = 0 ; i < del . length ; i ++ ) { if ( c == del [ i ] ) { list = list . substring ( 1 ) ; continue outer ; } } break ; } int len ; outer : while ( list . length ( ) > 0 ) { c = list . charAt ( list . length ( ) - 1 ) ; for ( int i = 0 ; i < del . length ; i ++ ) { if ( c == del [ i ] ) { len = list . length ( ) ; list = list . substring ( 0 , len - 1 < 0 ? 0 : len - 1 ) ; continue outer ; } } break ; } return listToArray ( list , delimiter ) ; }
casts a list to array object , remove all empty items at start and end of the list
