Enkapsulasi khusus kelas alat umum untuk referensi Anda, konten spesifik adalah sebagai berikut
Paket com.demo.utils; import java.util.arraylist; import java.util.list; import java.util.map;/** * Kelas Operasi String * @Author Dongyangyang * @Date 2016/12/28 23:12 * @version 1.0 */class public class @Public String {leving * {verpase * {version * @version * string statis public firstChartolowerCase (string str) {char firstChar = str.charat (0); if (firstchar> = 'a' && firstChar <= 'z') {char [] arr = str.tochararray (); arr [0] += ('a' - 'a'); mengembalikan string baru (arr); } return str; } / ** * Surat awal menjadi dikapitalisasi * @param str * @return * / public static String firstChartoPpercase (string str) {char firstChar = str.charat (0); if (firstchar> = 'a' && firstChar <= 'z') {char [] arr = str.tochararray (); arr [0] - = ('a' - 'a'); mengembalikan string baru (arr); } return str; } / ** * Tentukan apakah itu kosong * @param str * @return * / public static boolean isempty (string final str) {return (str == null) || (str.length () == 0); } / ** * Tentukan apakah itu tidak kosong * @param str * @return * / public static boolean isNoTempty (string final str) {return! Isempty (str); } / ** * 1. Tentukan apakah itu kosong * @param str * @return * / public static boolean isBlank (string final str) {int strlen; if ((str == null) || ((strlen = str.length ()) == 0)) Return true; untuk (int i = 0; i <strlen; i ++) {if (! karakter.iswhitespace (str.charat (i))) {return false; }} return true; } / ** * Tentukan apakah itu tidak kosong * @param str * @return * / public static boolean isNotBlank (string final str) {return! IsBlank (str); } / ** * Tentukan apakah semua string ganda kosong * string @param * @return * / public static boolean isAllEmty (string ... string) {if (string == null) {return true; } untuk (string str: string) {if (isNotEmpty (str)) {return false; }} return true; } / ** * Tentukan apakah ada beberapa string yang kosong * @param string * @return * / public static boolean isHasEmpty (string ... string) {if (string == null) {return true; } untuk (string str: string) {if (isEmpty (str)) {return true; }} return false; } / ** * DefaultValue adalah null atau "" * @param checkValue * @param defaultValue * @return * / public static string isempty (string checkValue, string defaultValue) {return isempty (checkValue)? DefaultValue: CheckValue; } / ** * String tidak nol dan bukan "" dan sama dengan * @param str * @param lainnya * @return * / public static boolean isNoTEmpty dan equelsother (string str, string lainnya) {if (isempty (str)) {return false; } return str.Equals (lainnya); } / ** * String itu bukan nol dan bukan "" dan tidak sama dengan * @param str * @param lainnya * @return * / public static boolean isNoTemptyAndnotequelsother (string str, string ... lain) {if (isEmpty (str)) {return false; } untuk (int i = 0; i <Other.length; i ++) {if (str.equals (lain [i])) {return false; }} return true; } / ** * String tidak sama dengan * @param str * @param lainnya * @return * / public static boolean isnotequelsother (string str, string ... Other) {for (int i = 0; i <Other.length; i ++) {if (lain [i] .Equals (str)) {return false; }} return true; } / ** * menilai string tidak kosong * @param string * @return * / public static boolean isNoTempty (string ... string) {if (string == null) {return false; } untuk (string str: string) {if (str == null || "" .equals (str.trim ())) {return false; }} return true; } / ** * Karakter Perbandingan Equal * @param Nilai * @param sama * @return * / public static boolean sama (nilai string, string sama) {if (isAllEmty (value, equals)) {return true; } return value.equals (sama); } / ** * String perbandingan tidak sama * @param nilai * @param sama * @return * / public static boolean isNotequals (nilai string, string equals) {return! Equals (value, equals); } public static string [] split (string content, string sparatorchars) {return splitWorker (konten, sparatorchars, -1, false); } public static string [] split (string str string, string sparatorchars, int max) {return splitworker (str, sparatorchars, max, false); } public static final string [] empld_string_array = string baru [0]; Private Static String [] splitWorker (string str string, string separatorchars, int max, boolean preservealltokens) {if (str == null) {return null; } int len = str.length (); if (len == 0) {return empted_string_array; } Daftar <String> Daftar = ArrayList baru <string> (); int sizeplus1 = 1; int i = 0, mulai = 0; pertandingan boolean = false; boolean lastmatch = false; if (pitaoTchars == null) {while (i <len) {if (karakter.isWhitespace (str.charat (i))) {if (match || preservealltokens) {lastmatch = true; if (sizeplus1 ++ == max) {i = len; lastmatch = false; } list.add (str.substring (start, i)); cocok = false; } start = ++ i; melanjutkan; } lastmatch = false; cocok = true; i ++; }} lain if (petaTatorChars.length () == 1) {char sep = pitaoTarchars.charat (0); while (i <len) {if (str.charat (i) == sep) {if (match || preservealltokens) {lastmatch = true; if (sizeplus1 ++ == max) {i = len; lastmatch = false; } list.add (str.substring (start, i)); cocok = false; } start = ++ i; melanjutkan; } lastmatch = false; cocok = true; i ++; }} else {while (i <len) {if (petaTatorChars.indexof (str.charat (i))> = 0) {if (match || preservealltokens) {lastmatch = true; if (sizeplus1 ++ == max) {i = len; lastmatch = false; } list.add (str.substring (start, i)); cocok = false; } start = ++ i; melanjutkan; } lastmatch = false; cocok = true; i ++; }} if (cocok || (preservealltokens && lastmatch)) {list.add (str.substring (start, i)); } return (string []) list.toArray (kosong_string_array); } / ** * Hilangkan karakter pelarian * @param str * @return * / public static string Escapexml (string str) {if (str == null) return ""; StringBuilder SB = StringBuilder baru (); untuk (int i = 0; i <str.length (); ++ i) {char c = str.charat (i); switch (c) {case '/u00ff': case '/u0024': break; case '&': SB.Append ("&"); merusak; kasus '<': sb.append ("<"); merusak; case '>': sb.append (">"); merusak; case '/"': SB.Append (" "); break; case '/' ': sb.append (" "); break; case'/'': sb.append (" '); break; default: if (c> ='/u0000 '&& c <='/u001f ') break; if (c> ='/ue 000 '& c <='/u001f ') break; if (c> ='/ue 000 /UFFF0 '&& C <='/UFFF ') Break; s, peta <String, Object> MAP) {StringBuilder ret = New StringBuilder ((int) (s.length () * 1.5)); Ret.pen (s.substring (kursor, start)). append (map.get (s.substring (start + 2, end)))); OBJS.Length == 0) Return S; Ret.Sebah (STRINGSTRICE (CURSOR, MULAI)); Harus ditandai dalam gaya seperti {0}. {if (params == null || params.length == 0 || Sumber == NULL || SOURDE. (Params] == NULL) {Param = NULL; endIndex); (s) || pemisah == null) {return s; = null ||. string final pemisah) {if (isempty (str)) {return str stred; String toString (byte [] bytes) {coba {return new string (bytes, "utf-8"); str.getbytes (UTF-8 ");Di atas adalah semua konten artikel ini. Saya berharap ini akan membantu untuk pembelajaran semua orang dan saya harap semua orang akan lebih mendukung wulin.com.