code: public static String[] split(String str, String separator, boolean trim) {
          if (str == null) {
              return null;
          }
  
          char sep = separator.charAt(0);
  
          ArrayList<String> strList = new ArrayList<String>();
          StringBuilder split = new StringBuilder();
          int index = 0;
          while ((index = StringUtils.findNext(str, sep, StringUtils.ESCAPE_CHAR, index, split)) >= 0) {
              ++index; // move over the separator for next search
              strList.add(split.toString());
              split.setLength(0); // reset the buffer
          }
  
          strList.add(split.toString());
          // remove trailing empty split(s)
          if (trim) {
              int last = strList.size(); // last split
              while (--last>=0 && "".equals(strList.get(last))) {
                  strList.remove(last);
              }
          }
  
          return strList.toArray(new String[strList.size()]);
      }
docs: splits this string around matches of the given separator.
  @param str strings
  @param separator separator
  @param trim include the last separator
  @return the array of strings computed by splitting this string around matches of the given separator