1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. sun認證考試java字符串處理技巧

        時間:2020-09-21 12:31:58 SUN認證 我要投稿

        sun認證考試java關于字符串處理技巧

          關于字符串的一些處理方法現(xiàn)在跟大家分享下我的.總結:

        sun認證考試java關于字符串處理技巧

          * @版本 1.0

          */

          public class StringUtil {

          public StringUtil() {

          }

          /**

          * @description 字符串替代函數(shù)

          * @param source String 源字符串

          * @param be_rep_str String 需要被替換的子串

          * @param rep_str String 要替換的目標串

          * @param return_str String

          * @return String

          */

          public static String replaceStr(String source, String be_rep_str,

          String rep_str, String return_str) {

          if (source.indexOf(be_rep_str) < 0) {

          return source;

          }

          else {

          String head = source.substring(0, source.indexOf(be_rep_str));

          String body = rep_str +

          source.substring(source.indexOf(be_rep_str) + be_rep_str.length());

          return_str = replaceStr(head + body, be_rep_str, rep_str,

          return_str);

          }

          return return_str;

          }

          public static String[] getFields(String test, String sep) { //坼分字符,將字句test按照sep進行坼分。

          sep = "u0020";

          if (test.indexOf(sep) != -1) {

          if ( (test.indexOf(sep) > test.indexOf("#")) &&

          test.indexOf("#") != -1) {

          sep = "#";

          }

          }

          else {

          sep = "#";

          }

          String[] st;

          List flds = new ArrayList();

          if (sep.equals("u0020")) {

          StringTokenizer stto = new StringTokenizer(test.trim(), sep);

          while (stto.hasMoreTokens()) {

          flds.add(stto.nextToken());

          }

          st = (String[]) flds.toArray(new String[stto.countTokens()]);

          }

          else {

          st = test.trim()。split(sep);

          }

          return st;

          }

          // public String DBC2SBC(String str)

          // {

          // int i ;

          // String result = "";

          // for (i = 0 ; i < str.length(); i++)

          // {

          // code = str.charCodeAt(i) ;

          // // "65281"是"!","65373"是"}"

          // if (code >= 65281 && code < 65373)

          // // "65248"是轉換碼距

          // result += String.fromCharCode(str.charCodeAt(i) - 65248) ;

          // else

          // result += str.charAt(i) ;

          // }

          // return result ;

          // }

          /**

          * 半角 DBC case -> 全角 SBC case

          * @param QJstr String

          * @return String

          */

          public static final String BQchange(String QJstr) {

          String outStr = "";

          String Tstr = "";

          byte[] b = null;

          for (int i = 0; i < QJstr.length(); i++) {

          try {

          Tstr = QJstr.substring(i, i + 1);

          b = Tstr.getBytes("unicode");

          }

          catch (java.io.UnsupportedEncodingException e) {

          e.printStackTrace();

          }

          if (b[3] != -1) {

          b[2] = (byte) (b[2] - 32);

          b[3] = -1;

          try {

          outStr = outStr + new String(b, "unicode");

          }

          catch (java.io.UnsupportedEncodingException e) {

          e.printStackTrace();

          }

          }

          else {

          outStr = outStr + Tstr;

          }

          }

          return outStr;

          }

          /**

          * 全角 轉換成 -> 半角

          * @param QJstr String

          * @return String

          */

          public static final String QBchange(String QJstr) {

          String outStr = "";

          String Tstr = "";

          byte[] b = null;

          for (int i = 0; i < QJstr.length(); i++) {

          try {

          Tstr = QJstr.substring(i, i + 1);

          b = Tstr.getBytes("unicode");

          }

          catch (java.io.UnsupportedEncodingException e) {

          e.printStackTrace();

          }

          if (b[3] == -1) {

          b[2] = (byte) (b[2] + 32);

          b[3] = 0;

          try {

          outStr = outStr + new String(b, "unicode");

          }

          catch (java.io.UnsupportedEncodingException e) {

          e.printStackTrace();

          }

          }

          else {

          outStr = outStr + Tstr;

          }

          }

          return outStr;

          }

          public static void main(String aa[]) {

          String qj = "#?$%……?*()";

          String bj = "#@$%^&*()";

          System.out.println("半角轉換成全角:" + bj + " ——> " + BQchange(bj));

          String s = " ";

          String qs = " ";

          System.out.println("全角轉換成半角:"+qj + " ——>" + QBchange(qj));

          System.out.println( (int) (QBchange(qs)。toCharArray()[0]));

          System.out.println( (int) s.toCharArray()[0]);

          String dd[] = getFields("23#99#99#99", "#");

          for (int i = 0; i < dd.length; i++) {

          System.out.println("asfd" + dd[i]);

          }

          System.out.println(dd.length);

          }

          }

        【sun認證考試java關于字符串處理技巧】相關文章:

        sun認證java關于字符串處理技巧11-08

        Sun java認證考試答案11-12

        Sun Java認證考試科目10-03

        sun java認證考試介紹10-03

        sun java認證考試報考指南10-03

        Sun認證Java程序員考試技巧分享11-05

        SUN JAVA認證介紹05-13

        Sun java認證考試真題答案07-19

        Sun認證Java開發(fā)員考試介紹10-25

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>