stringsplit.java

来自「j2me实现的移动警务的大概框架」· Java 代码 · 共 77 行

JAVA
77
字号
package PoliceSearch.Com;

/**
 * <p>Title: 公安查询系统</p>
 * <p>Description: 章桂华</p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: otheno</p>
 * @author 章桂华等
 * @version 1.0
 */
/**
 * <p>Title: 公安查询系统</p>
 * <p>Description: 章桂华</p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: otheno</p>
 * @author 章桂华等
 * @version 1.0
 */
import java.util.*;

public class StringSplit {

  public StringSplit() {
  }

  /**
   * @function:toArray,将一长字符串以固定的参数字符串打断
   * @Return String[] 返回字符串数组
   */
  public static String[] toArray(String ST_StrValues, String ST_StrSplitPara) {
    int l, i, j, len1;
    Vector Vec_V1 = new Vector();
//    String ST_StrValues = new String(strDelValues);
    try {
      if ( (ST_StrValues == null) || (ST_StrSplitPara == null)) {
        String[] ST_StrTemp3 = new String[1];
        ST_StrTemp3[0] = "";
        return ST_StrTemp3;
      }

      if (ST_StrSplitPara.length() <= 0) {
        String[] ST_StrTemp4 = new String[1];
        ST_StrTemp4[0] = ST_StrValues;
        return ST_StrTemp4;
      }

      l = 0;
      if (ST_StrValues.length() < 0) {
        return null;
      }
      j = 0;
      for (len1 = 0; ST_StrValues.length() > 0; len1++) {
        j = ST_StrValues.indexOf(ST_StrSplitPara, 0);
        if (j == -1) {
          break;
        }
        else {
          Vec_V1.addElement(ST_StrValues.substring(0, j));
          ST_StrValues = ST_StrValues.substring(j + ST_StrSplitPara.length(),
                                                ST_StrValues.length());
        }
      }
      Vec_V1.addElement(ST_StrValues);
      String[] ST_StrTemp = new String[Vec_V1.size()];
      for (i = 0; i < Vec_V1.size(); i++) {
        ST_StrTemp[i] = (String) Vec_V1.elementAt(i);
      }
      Vec_V1.removeAllElements();
      return ST_StrTemp;
    }
    catch (NullPointerException e) {
      Log.except(e.toString());
      return null;
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?