public static String trim(String str)
  {
    String result = str;
    StringBuffer temp = null;
    if ((result == null) || (result.trim().length() == 0)) {
      return result;
    }
    temp = new StringBuffer("");
    for (int i = 0; i < result.length(); i++) {
      if (result.charAt(i) != ' ')
      {
        temp.append(result.charAt(i));
      }
    }
    result = temp.toString();

    return result;
  }