星期三, 八月 01, 2007

StringUtil


package sample;

import java.util.StringTokenizer;
/**

  * StringUtil
  */
public class StringUtil {
         /**
          * 文字列の分割(区切り文字指定)
          * @param str 対象文字列
          * @param delim 区切り文字列
          * @return 分割後の文字列
          */
         public static String[] split(String str, String delim) {
                  StringTokenizer st = new StringTokenizer(str, delim);
                  int length = st.countTokens();
                  String[] result = new String[length];
                  for (int i = 0; i < length; i++) {
                      result[i] = st.nextToken();
                  }
                  return result;
         }

}

没有评论: