乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Jakarta Commons學(xué)習(xí)筆記之RandomStringUtils常用方法和實(shí)現(xiàn)

       pengx 2009-03-17

      1. 創(chuàng)建
          靜態(tài)類
      2. public static String random(int count, int start, int end, boolean letters, boolean numbers,                                   char[] chars, Random random)
          用途:產(chǎn)生根據(jù)參數(shù)描述的隨機(jī)字符串。
          參數(shù):count,產(chǎn)生的隨機(jī)字符長(zhǎng)度;start,隨機(jī)字符選擇集的起始位置;end,隨機(jī)字符選擇集的結(jié)束位置; letters,是否全為字符; numbers,是否全為數(shù)字;chars,字符選擇集合;random,隨機(jī)
          實(shí)現(xiàn):
          public static String random(int count, int start, int end, boolean letters, boolean numbers,
                                      char[] chars, Random random) {
              if (count == 0) {
                  return "";
              } else if (count < 0) {
                  throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
              }
              if ((start == 0) && (end == 0)) {
                  end = 'z' + 1;
                  start = ' ';
                  if (!letters && !numbers) {
                      start = 0;
                      end = Integer.MAX_VALUE;
                  }
              }

              char[] buffer = new char[count];
              int gap = end - start;

              while (count-- != 0) {
                  char ch;
                  if (chars == null) {
                      ch = (char) (random.nextInt(gap) + start);
                  } else {
                      ch = chars[random.nextInt(gap) + start];
                  }
                  if ((letters && Character.isLetter(ch))
                      || (numbers && Character.isDigit(ch))
                      || (!letters && !numbers))
                  {
                      if(ch >= 56320 && ch <= 57343) {
                          if(count == 0) {
                              count++;
                          } else {
                              // low surrogate, insert high surrogate after putting it in
                              buffer[count] = ch;
                              count--;
                              buffer[count] = (char) (55296 + random.nextInt(128));
                          }
                      } else if(ch >= 55296 && ch <= 56191) {
                          if(count == 0) {
                              count++;
                          } else {
                              // high surrogate, insert low surrogate before putting it in
                              buffer[count] = (char) (56320 + random.nextInt(128));
                              count--;
                              buffer[count] = ch;
                          }
                      } else if(ch >= 56192 && ch <= 56319) {
                          // private high surrogate, no effing clue, so skip it
                          count++;
                      } else {
                          buffer[count] = ch;
                      }
                  } else {
                      count++;
                  }
              }
              return new String(buffer);
          }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多