التغليف المخصص لفئات الأدوات الشائعة للرجوع إليه ، المحتوى المحدد هو كما يلي
package com.demo.utils ؛ import java.util.arraylist ؛ import java.util.list ؛ import java.util.map ؛/** * string string class * @author dongyangyang * @date 2016/12/28 23:12 * @version 1.0 */public class string { String FirstChartOlowerCase (String str) {char firstchar = str.charat (0) ؛ if (firstchar> = 'a' && firstchar <= 'z') {char [] arr = str.tochararray () ؛ arr [0] += ('a' - 'a') ؛ إرجاع سلسلة جديدة (ARR) ؛ } إرجاع str ؛ } / ** * يصبح الحرف الأولي مغرّنًا * param str * @regurn * / string static public firstChartOupperCase (String str) {char firstchar = str.charat (0) ؛ if (firstchar> = 'a' && firstchar <= 'z') {char [] arr = str.tochararray () ؛ arr [0] - = ('a' - 'a') ؛ إرجاع سلسلة جديدة (ARR) ؛ } إرجاع str ؛ } / ** * حدد ما إذا كان فارغًا * param str * @return * / public static boolean isEmpty (Final String str) {return (str == null) || (str.length () == 0) ؛ } / ** * حدد ما إذا كان غير فارغ * param str * @return * / public static boolean isnotempty (final string str) {return! isempty (str) ؛ } / ** * 1. if ((str == null) || ((strlen = str.length ()) == 0)) return true ؛ لـ (int i = 0 ؛ i <strlen ؛ i ++) {if (! character.ishitespace (str.charat (i))) {return false ؛ }} إرجاع صحيح ؛ } / ** * حدد ما إذا كان ليس فارغًا * param str * @return * / public static boolean isnotblank (Final String str) {return! isBlank (str) ؛ } / ** * حدد ما إذا كانت جميع الأوتار المتعددة فارغة * param strings * return * / public static boolean isAllEmpty (سلسلة ... سلاسل) {if (strings == null) {return true ؛ } لـ (String str: strings) {if (isnotempty (str)) {return false ؛ }} إرجاع صحيح ؛ } / ** * حدد ما إذا كان أي من الأوتار المتعددة فارغة * param سلاسل * @REGRANT * / public static boolean ishasempty (سلسلة ... سلاسل) {if (strings == null) {return true ؛ } لـ (String str: strings) {if (isempty (str)) {return true ؛ }} إرجاع خطأ ؛ } / ** * DefaultValue هو فارغ أو "" * param checkValue * param defaultValue * @return * / string static static isEmpty (سلسلة checkValue ، سلسلة defaultValue) {return isempty (checkValue)؟ DefaultValue: CheckValue ؛ } / ** * السلسلة ليست فارغة وليس "" ولا تساوي * param str * param other * @return * / public static boolean isnotemptyandequelsotherotherotherotherotherotherotherotherother (سلسلة str ، سلسلة أخرى) {if (isempty (str)) {return false ؛ } إرجاع str.equals (آخر) ؛ } / ** * السلسلة ليست خالية وليس "" ولا تساوي * stram str * param other * @return * / public static boolean isnotemptyandnotequelsotherotherothereothereother (String str ، string ... other) {if (isempty (str)) {return false ؛ } لـ (int i = 0 ؛ i <other.length ؛ i ++) {if (str.equals (other [i])) {return false ؛ }} إرجاع صحيح ؛ } / ** * السلسلة لا تساوي * param str * param other * @return * / public static boolean isnotequelsother (String str ، string ... other) {for (int i = 0 ؛ i <other.length ؛ i ++) {if (other [i]. }} إرجاع صحيح ؛ } / ** * احكم على السلسلة غير فارغة * param سلاسل * return * / public static boolean isnotempty (سلسلة ... سلاسل) {if (strings == null) {return false ؛ } لـ (String Str: Strings) {if (str == null || "" .equals (str.trim ())) {return false ؛ }} إرجاع صحيح ؛ } / ** * أحرف المقارنة متساوية * param value * param equals * @return * / public static boolean متساوية (قيمة السلسلة ، السلسلة متساوية) {if (isAllempty (value ، equals)) {return true ؛ } قيمة الإرجاع. } / ** * سلاسل المقارنة ليست متساوية * param value * param متساوية * @return * / public static boolean isnotequals (قيمة السلسلة ، السلسلة متساوية) {return! equals (value ، equals) ؛ } السلسلة الثابتة العامة [] split (محتوى السلسلة ، فاصل السلسلة) {return splitworker (المحتوى ، الفاصل ، -1 ، خطأ) ؛ } سلسلة ثابتة عامة [] split (String str ، string seffenatorchars ، int max) {return splitworker (str ، sepanatorchars ، max ، false) ؛ } السلسلة النهائية الثابتة العامة [] فارغة_tring_array = سلسلة جديدة [0] ؛ سلسلة ثابتة خاصة [] SPLISTWORKER (String str ، string seffelaterchars ، int max ، boolean proservealltokens) {if (str == null) {return null ؛ } int len = str.length () ؛ if (len == 0) {return frept_string_array ؛ } قائمة <String> list = new ArrayList <String> () ؛ int sizeplus1 = 1 ؛ int i = 0 ، ابدأ = 0 ؛ مطابقة منطقية = خطأ ؛ Boolean LastMatch = false ؛ if (QuipatorChars == null) {بينما (i <len) {if (character.ishitespace (str.charat (i)))) {if (match || proservealltokens) {lastMatch = true ؛ if (sizeplus1 ++ == max) {i = len ؛ LastMatch = خطأ ؛ } list.add (str.substring (start ، i)) ؛ تطابق = خطأ ؛ } start = ++ i ؛ يكمل؛ } lastMatch = false ؛ تطابق = صحيح ؛ i ++ ؛ }} آخر if (explatorchars.length () == 1) {char sep = explatorchars.charat (0) ؛ بينما (i <len) {if (str.charat (i) == sep) {if (match || proservealltokens) {lastMatch = true ؛ if (sizeplus1 ++ == max) {i = len ؛ LastMatch = خطأ ؛ } list.add (str.substring (start ، i)) ؛ تطابق = خطأ ؛ } start = ++ i ؛ يكمل؛ } lastMatch = false ؛ تطابق = صحيح ؛ i ++ ؛ }} else {بينما (i <len) {if (QuiporatorShars.Indexof (str.charat (i))> = 0) {if (match || proservealltokens) {lastMatch = true ؛ if (sizeplus1 ++ == max) {i = len ؛ LastMatch = خطأ ؛ } list.add (str.substring (start ، i)) ؛ تطابق = خطأ ؛ } start = ++ i ؛ يكمل؛ } lastMatch = false ؛ تطابق = صحيح ؛ i ++ ؛ }} if (match || (proservealltokens && lastMatch))) {list.add (str.substring (start ، i)) ؛ } return (string []) list.toarray (fmare_string_array) ؛ } / ** * القضاء على أحرف الهروب * param str * return * / public Static String EscapexMl (String str) {if (str == null) return "" ؛ StringBuilder sb = new StringBuilder () ؛ لـ (int i = 0 ؛ i <str.length () ؛ ++ i) {char c = str.charat (i) ؛ Switch (c) {case '/u00ff': case '/u0024': break ؛ Case '&': sb.append ("&") ؛ استراحة؛ حالة '<': sb.append ("<") ؛ استراحة؛ Case '>': sb.append (">") ؛ استراحة؛ الحالة "/" ": sb.append (" ") ؛ break ؛ case '/' ': sb.append (" ") ؛ break ؛ case'/'': sb.append ( /ufff0 '&& c <='/ufff) S ، MAP <String ، Object> map) {StringBuilder Ret = new StringBuilder ((int) (S.Length () * 1.5) ؛ Ret.Append (S.SubString (STARTH). Objs.Length == 0) Ret.Append (S.SubString ، يجب أن يتم وضع علامة على نمط مثل {0}. {if (params == null || (COUNT] == NULL) (startIndex == -1) {break ؛ == null) {return s ؛ {return null ؛ (isempty) {return str ؛ Bytes) {try {return new string (bytes ، "utf-8") ؛ } catch (Unsupportedencodexception e) {return null ؛ما سبق هو كل محتوى هذه المقالة. آمل أن يكون ذلك مفيدًا لتعلم الجميع وآمل أن يدعم الجميع wulin.com أكثر.