public static String[] split(String toSplit, char delim, boolean ignoreEmpty) {
    StringBuffer buffer = new StringBuffer();
    Stack stringStack = new Stack();
    for (int i = 0; i < toSplit.length(); i++) {
      if (toSplit.charAt(i) != delim) {
        buffer.append((char) toSplit.charAt(i));
      } else {
        if (buffer.toString().trim().length() == 0 && ignoreEmpty) {
        } else {
          stringStack.addElement(buffer.toString());
        }
        buffer = new StringBuffer();
      }
    }
    if (buffer.length() != 0) {
      stringStack.addElement(buffer.toString());
    }
    String[] split = new String[stringStack.size()];
    for (int i = 0; i < split.length; i++) {
      split[split.length - 1 - i] = (String) stringStack.pop();
    }
    stringStack = null;
    buffer = null;
    return split;
  }