Benutzerdefinierte Kapselung gemeinsamer Werkzeugklassen für Ihre Referenz, der spezifische Inhalt ist wie folgt
package com.demo.utils;import java.util.ArrayList;import java.util.List;import java.util.Map;/** * String operation tool class* @author dongyangyang * @Date 2016/12/28 23:12 * @Version 1.0 * */public class StringUtils { /** * The initial letter is lowercase* @param str * @return */ public statische String FirstChartOrowerCase (String str) {char firstchar = str.charat (0); if (firstChar> = 'a' && FirstChar <= 'z') {char [] arr = str. tocharArray (); arr [0] += ('a' - 'a'); Neue Zeichenfolge zurückgeben (arr); } return str; } / ** * Der anfängliche Buchstaben wird kapitalisiert * @param str * @return * / public static String firstchartouppercase (String str) {char firstchar = str.charat (0); if (firstChar> = 'a' && FirstChar <= 'z') {char [] arr = str. tocharArray (); arr [0] - = ('a' - 'a'); Neue Zeichenfolge zurückgeben (arr); } return str; } / ** * Bestimmen Sie, ob es leer ist (Str.Length () == 0); } / ** * Bestimmen Sie, ob es nicht leer ist } / ** * 1. Bestimmen Sie, ob es leer ist if ((str == null) || ((strlen = str.length ()) == 0)) return true; für (int i = 0; i <strlen; i ++) {if (! charakter.iswhITespace (str.charat (i))) {return false; }} return true; } / ** * Bestimmen Sie, ob es nicht leer ist } / ** * Bestimmen Sie, ob alle mehrere Zeichenfolgen leer sind } für (String str: Strings) {if (isnotEmpty (str)) {return false; }} return true; } / ** * Bestimmen Sie, ob mehrere Zeichenfolgen leer sind } für (string str: strings) {if (isEmpty (str)) {return true; }} return false; } / ** * defaultValue ist null oder "" * @param checkValue * @param DefaultValue * @return * / public static String isEmpty (String checkValue, String defaultValue) {return isempy (checkValue)? StandardValue: checkValue; } / ** * Die Zeichenfolge ist nicht null und nicht "" und gleich anderen * @param str * @param Andere * @return * / public static boolean isnotEmptyAndAnequelsother (String Str, String other) {if (isEmpty (str)) {return false; } return str.equals (andere); } / ** * Die Zeichenfolge ist nicht null und nicht "" und nicht gleich anderer * @param str * @param andere * @return * / public static boolean isnotEmptyAndNotequelsother (String Str, String ... Other) {if (isempty (str)) {return false; } für (int i = 0; i <other.length; i ++) {if (str.equals (andere [i])) {return false; }} return true; } / ** * String ist nicht gleich anderer * @param str * @param other * @return * / public static boolean isNotequelsother (String str, String ... other) {für (int i = 0; i <other.Length; i ++) {if (andere [i] .Equals (str)) {return caa return; }} return true; } / ** * beurteilen Sie die Zeichenfolge, die nicht leer ist } für (String str: Strings) {if (str == null || "" .Equals (str.trim ())) {return false; }} return true; } / ** * Vergleichszeichen gleich * @param value * @param equals * @return * / public static boolean Equals (String -Wert, String Equals) {if (isAllEmpty (Wert, Equals)) {return true; } return value.equals (gleich); } / ** * Vergleichszeichenfolgen sind nicht gleich * @param value * @param equals * @return * / public static boolean isNotequals (String -Wert, String Equals) {return! Equals (Wert, Equals); } public static String [] split (String -Inhalt, String -SeparatorChars) {return splitworker (Inhalt, Separatorchars, -1, false); } public static String [] split (String str, String -Separatorchars, int max) {return splittraworker (str, trennungsseparator, max, false); } public static final String [] leer_string_array = new String [0]; private statische String [] Splitworker (String str, String Separatorchars, int max, boolean PreserveAltokens) {if (str == null) {return null; } int len = str.length (); if (len == 0) {return lese_string_array; } List <string> list = new ArrayList <string> (); int sizeplus1 = 1; int i = 0, start = 0; boolean Match = false; boolean lastMatch = false; if (separatorChars == null) {while (i <len) {if (charakter.iswhITespace (str.charat (i))) {if (Match || preserveAltokens) {lastMatch = true; if (sizeplus1 ++ == max) {i = len; lastMatch = false; } list.add (Str.Substring (Start, i)); Match = false; } start = ++ i; weitermachen; } lastMatch = false; Match = true; i ++; }} else if (separatorChars.length () == 1) {char sep = separatorChars.charat (0); while (i <len) {if (str.charat (i) == sep) {if (match || preserveAltokens) {lastMatch = true; if (sizeplus1 ++ == max) {i = len; lastMatch = false; } list.add (Str.Substring (Start, i)); Match = false; } start = ++ i; weitermachen; } lastMatch = false; Match = true; i ++; }} else {while (i <len) {if (separatorchars if (sizeplus1 ++ == max) {i = len; lastMatch = false; } list.add (Str.Substring (Start, i)); Match = false; } start = ++ i; weitermachen; } lastMatch = false; Match = true; i ++; }} if (match || (preserveAltokens && lastMatch)) {list.add (Str.Substring (start, i)); } return (string []) list.toArray (leer_string_array); } / ** * ELEMINATE ESCAPTARS * @PARAM STR * @RETURN * / public static String Escapexml (String str) {if (str == null) return ""; StringBuilder sb = new StringBuilder (); für (int i = 0; i <str.length (); ++ i) {char c = str.charat (i); Switch (c) {case '/u00ff': case '/u0024': break; Fall '&': SB.Append ("&"); brechen; Fall '<': sb.append ("<"); brechen; case '>': sb.append (">"); brechen; case '/"': sb.append (" "); break; case '/' ': sb.append (" "); break; case'/'': sb.append (" '"); Standard: if (c> ='/u0000 '&& c <='/u001f ') break; '/UFFF0' && c <= '/UFFF') Break; S, Map <String, Object> map) {StringBuilder ret = new StringBuilder ((int) (s.Length () * 1.5); Start) (S.Intexof ("{}") == -1 return s; OBJS.Length) Ret.Append (OBJS [Index]) * * @param Quelle null || params [count] .toString (); startindex + temp.length (); (separator.isempty ()) {return ""; Str.Indexof (Open); } if (separator == null) {return ""; String (Bytes, "UTF-8"); (UnsupportedenCodingException E) {return null;Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.