当前位置: 首页 > 工具软件 > Hutool > 使用案例 >

Hutool工具类和工具方法

羊舌阎宝
2023-12-01

基础工具类:

StrUtil/StringUtils -字符串工具类
添加移除:addXXX/appendXXX/removeXXX
  
判断:containsXXX/startWithXXX/endWithXXX/indexOfXXX/lastIndexOfXXX/ordinalIndexOf/
    isAllCharMatchisBlankIfStr/isBlankOrUndefined/isNullOrUndefined/hasBlank/hasEmpty/
    isEmpty/isNotEmpty/isAllBlank/isBlank/isNotBlank/isEmptyIfStr/isEmptyOrUndefined/
    isLowerCase//isUpperCase/isWrap/isSubEquals/isSurround
获取:genGetter/genSetter/getReader/getWriter/getContainsStr/getContainsStrIgnoreCase/getGeneralField/
	length/maxLength/totalLength/uuid/utf8Bytes/utf8Str/
转换:blankToDefault/nullToXXX/emptyIfNull/emptyToXXX/toCamelCase/toSymbolCase/toUnderlineCase/
操作:subXXX/cleanBlank/concat/count/format/hide/join/fill/fillAfter/fillBefore/filter/lowerFirst/reverse/padAfter/padPre/
	repeatXXX/trimStart/trimToEmpty/trimToNull/splitXXX/replacXXXunWrapXXX/upperFirstAndAddPre/
其他: brief/center/move/similar/strip/stripIgnoreCase/str/strBuilder/builder/swapCase/cut/bytes/byteBuffer/byteLength/
	compare/compareIgnoreCase/compareVersion/prependIfMissing/prependIfMissingIgnoreCase/
DateUtil-日期工具类
创建:calendar/dateNew/timer/createStopWatch/
获取: age/year/month/date/hour/minute/second/millsecond/millisecond/
	 now/today/yesterday/tomorrow/ageOfNow/quarter/yearAndQuarter/
	 current/currentSeconds/dateSecond/ thisWeekOfYear/thisWeekOfMonth/thisDayOfWeek/thisDayOfMonth/
     thisYear/thisMonth/thisHour/thisMinute/thisSecond/thisMillsecond/thisMillisecond/thisDayOfWeekEnum/thisMonthEnum/
	dayOfMonth/dayOfWeek/dayOfWeekEnum/dayOfYear/endOfDay/endOfMonth/endOfQuarter/endOfSecond/endOfWeek/endOfYear/
	beginOfDay/beginOfMonth/beginOfQuarter/beginOfSecond/beginOfWeek/beginOfYear/weekOfMonth/weekOfYear/
	lastMonth/lastWeek/lengthOfYear/weekCount/monthEnum/quarterEnum/nextMonth/nextWeek/
格式化:format/formatBetween/formatChineseDate/formatDate/formatDateTime/formatHttpDate/formatLocalDateTime/formatTime/
判断:isAM/isPM/isLeapYear/isSameDay/isSameInstant/isSameTime/isExpired/isIn/
转换:parse/parseByPatterns/parseCST/parseDate/parseDateTime/parseLocalDateTime/parseTime/parseTimeToday/parseUTC/
	toInstant/toIntSecond/toLocalDateTime/timeToSecond/secondToTime/nanosToMillis/nanosToSeconds/
操作:offset/offsetDate/offsetDay/offsetHour/offsetMillisecond/offsetMinute/offsetMonth/offsetSecond/offsetWeek/
	 between/betweenDay/betweenMonth/betweenMs/betweenWeek/betweenYear/
其他:ceiling/round/truncate/compare/range/rangeToList/spendMs/spendNt/
NumberUtil-数字工具类
判断:isInteger/isLong/isNumber/isDouble/isPrimes/isLess/isLessOrEqual/isGreater/
	 isBlankChar/isBeside/isValidNumber/isGreaterOrEqual/
获取:max/min/count/decimalFormat/decimalFormatMoney/sub/getBinaryStr/
计算:add/ceilDiv/div/divisor/mul/multiple/processMultiple/sqrt/pow/compare/
创建:newBigInteger/generateBySet/generateRandomNumber/
转换:formatPercent/fromUnsignedByteArray/binaryToInt/binaryToLong/
	 arseInt/parseLong/parseNumber/partValue/null2Zero/toBigDecimal/toBytes/toInt/toStr/toUnsignedByteArray/zero2One/
其他:appendRange/range/round/roundDown/roundHalfEven/roundStr/factorial/

反射工具类:

BeanUtil-javaBean工具类
转换:toBean/beanToMap/mapToBean/toBeanIgnoreCase/toBeanIgnoreError/mapToBeanIgnoreCase/
获取:getBeanDesc/getFieldValue/getProperty/getPropertyDescriptor/getPropertyDescriptorMap/getPropertyDescriptors/
判断:isBean/isEmpty/isMatchName/isNotEmpty/isReadableBean/hasGetter/hasNullField/hasPublicField/hasSetter/
设置:setFieldValue/setProperty/fillBean/fillBeanWithMap/fillBeanWithMapIgnoreCase/
其他:copyProperties/createDynaBean/findEditor/trimStrFields/
ClassUtil-类工具类
获取:getPublicMethod/getPublicMethods/getPublicMethodNames/
     getDeclaredMethod/getDeclaredMethods/getDeclaredMethodNames/getDeclaredMethodOfObj/
 	 getDeclaredField/getDeclaredFields/ getLocation/getLocationPath/getPackage/getPackagePath/
     getContextClassLoader/getDefaultValue/getDefaultValues/getEnclosingClass/getJavaClassPaths/
     getResourceURL/getResourceUrl/getResources/getShortClassName/getTypeArgument/
判断:isAbstract/isAllAssignableFrom/isAssignable/isBasicType/isEnum/isJdkClass/isNormalClass/isNotPublic/
	isPrimitiveWrapper/isPublic/isSimpleTypeOrArray/isSimpleValueType/isStatic/isTopLevelClass/
操作:	invoke/loadClass/scanPackage/scanPackageByAnnotation/scanPackageBySuper/
其他:setAccessible/
ClassLoaderUtil-类加载器工具类
getContextClassLoader/getJarClassLoader/isPresent/loadClass/loadPrimitiveClass/
EnumUtil-枚举工具类
getEnumAt/getEnumMap/getFieldNames/getFieldValues/getNameFieldMap/getNames/
contains/fromString/fromStringQuietly/isEnum/likeValueOf/notContains/
ModifierUtil-修饰符工具类
hasModifier/isPublic/isStatic/
ObjectUtil-对象工具类
判断: isEmpty/isNotEmpty/isNull/isNotNull/isAllEmpty/isAllNotEmpty/isBasicType/isValidIfNumber/equal/notEqual/hasEmpty/
其他:clone/cloneByStream/cloneIfPossible/emptyCount/getTypeArgument/
	compare/contains/length/serialize/unserialize/deserialize/defaultIfBlank/defaultIfEmpty/defaultIfNull/
ReflectUtil-反射工具类
获取:getConstructor/getConstructors/getConstructorsDirectly/getField/getFieldMap/getFieldName/getFieldValue/getFields/getMethod/
    getFieldsDirectly/getFieldsValue/getMethodByName/getMethodByNameIgnoreCase/getMethodIgnoreCase/getStaticFieldValue/
	getMethodNames/getMethodOfObj/getMethods/getMethodsDirectly/getPublicMethod/getPublicMethodNames/getPublicMethods/
判断:isEmptyParam/isEqualsMethod/isHashCodeMethod/isToStringMethod/hasField/
操作:invoke/invokeStatic/invokeWithCheck/newInstance/newInstanceIfPossible/setAccessible/setFieldValue/
ServiceLoaderUtil-服务加载工具类
load/loadFirst/loadFirstAvailable/
TypeUtil-类型工具类
getActualType/getActualTypes/getFirstParamClass/getFirstParamType/getParamClass/getParamClasses/getParamType/
getParamTypes/getReturnClass/getReturnType/getType/getTypeArgument/getTypeArguments/
hasTypeVeriable/isUnknow/toParameterizedType/

集合工具类:

CollUtil/CollectionsUtils-通用集合工具类

常用方法:

  • isEmpty/isNotEmpty/contains/containsAll/containsAny
增减:addAll/addAllIfNotContains/removeAny/removeBlank/removeEmpty/
	 removeNull/clear/setOrAppend/
判断:contains/containsAll/containsAny/isEmpty/isNotEmpty/hasNull/
获取:get/getAny/getElementType/getFieldValues/getFirst/getLast/findOne/findOneByField/
	 fieldValueAsMap/fieldValueMap/indexOfAll/keySet/list/set/map/values/valuesOfKeys/
计算:count/countMap/max/min/
创建:create/createMap/newHashMap/newHashSet/newLinkedHashSet/empty/emptyIfNull/
	 newLinkedList/newArrayList/newBlockingQueue/newCopyOnWriteArrayList/
转换:toCollection/toList/toListMap/toMap/toMapList/toTreeSet/
	 defaultIfEmpty/ unmodifiable/
操作:sort/sortByEntry/sortByPinyin/sortByProperty/group/groupByField/
	sortEntryToList/sortPageAll/sortToMap/padLeft/padRight/filter/filterNew/
	asEnumeration/asIterable/asIterator/join
	/union/unionAll/unionDistinct/intersection/
	forEach/reverse/reverseNew/intersectionDistinct/distinct/
	sub/subtract/subtractToList/split/
其他:disjunction/extract/
分页:page/popPart
压缩:zip/
IterUtil-迭代器工具类
操作:asIterator/filter/toList/toListMap/toMap/countMap/join/
获取:fieldValueAsMap/fieldValueList/fieldValueMap/getElementType/getFirst/empty/hasNull/isAllNull/isEmpty/isNotEmpty/
ListUtil-List工具类
获取:indexOfAll/empty/page/setOrAppend/sub/
转换:toCopyOnWriteArrayList/toLinkedList/toList/unmodifiable/list/
操作:filter/reverse/reverseNew/sort/sortByPinyin/sortByProperty/
MapUtil-Map工具类
创建:newConcurrentHashMap/newHashMap/newIdentityMap/newTreeMap/of/
	  builder/createMap/createProxy/
获取:get/getAny/getBool/getChar/getDate/getDouble/
	 getFloat/getInt/getLong/getShort/getStr/
增减:clear/removeAny/removeNullValue/renameKey/
判断:isEmpty/isNotEmpty/
转换:toCamelCaseMap/toListMap/toMapList/toObjectArray/unmodifiable/wrap/
操作:defaultIfEmpty/empty/emptyIfNull/join/joinIgnoreNull/
	 ilter/inverse/reverse/sort/sortJoin/
ArrayUtil-数组工具类
增减:newArray/remove/removeBlank/removeEle/removeEmpty/removeNull/
	 insert/addAll/append/copy/clone/setOrAppend/
判断:contains/containsAny/containsIgnoreCase/hasEmpty/hasNull/
	 isAllEmpty/isAllNotEmpty/isAllNotNull/isAllNull/isArray/isEmpty/isNotEmpty/
获取:get/getAny/getArrayType/getComponentType/firstNonNull/defaultIfEmpty/
	indexOf/indexOfIgnoreCase/lastIndexOf/max/min/length/
操作:cast/distinct/filter/edit/join/range/resize/reverse/split/sub/unWrap/wrap/swap/
转换:toArray/zip/nullToEmpty/emptyCount/

IO流工具类

FileUtil
获取:getAbsolutePath/getAttributes/getBOMInputStream/getCanonicalPath/getInputStream/getLastPathEle/getLineSeparator/
    getMimeType/getName/getOutputStream/getParent/getPathEle/getPrefix/getPrintWriter/getReader/getSuffix/getTmpDir/
    getTmpDirPath/getType/getUserHomeDir/getUserHomePath/getUtf8Reader/getWebRoot/getWriter/
判断:isAbsolutePath/isDirEmpty/isDirectory/isEmpty/isFile/isModifed/isNotEmpty/isSub/isSymlink/isWindows/exist/extName/
	 newerThan/pathEndsWith/pathEquals/checkSlip/checksum/checksumCRC32/containsInvalid/contentEquals/contentEqualsIgnoreEOL/
读写:readBytes/readLine/readLines/readString/readUtf8Lines/readUtf8String/readableFileSize/
     writeBytes/writeFromStream/writeLines/writeMap/writeString/writeToStream/writeUtf8Lines/writeUtf8Map/writeUtf8String/
获取:size/listFileNames/lastModifiedTime/lastIndexOfSeparator/subPath/
操作:copy/copyContent/copyFile/copyFilesFromDir/newFile/move/tail/del/rename/ls/mkParentDirs/mkdir/load/loadUtf8/loopFiles/
	touch/appendLines/appendString/appendUtf8Lines/appendUtf8String/clean/cleanEmpty/cleanInvalid/
	createRandomAccessFile/createTempFile/convertCharset/convertLineSeparator/
其他:mainName/normalize/walkFiles/file/

实用工具类:

Convert
转换:toBigDecimal/toBigInteger/toBool/toBooleanArray/toByte/toByteArray/toChar/toCharArray/toCollection/toDBC/toDate/
	toDouble/toDoubleArray/toEnum/toFloat/toFloatArray/toHex/toInstant/toInt/toIntArray/toList/toLocalDateTime/toLong/
	toLongArray/toMap/toNumber/toNumberArray/toPrimitiveByteArray/toSBC/toShort/toShortArray/toStr/toStrArray/
	byteToUnsignedInt/bytesToInt/bytesToLong/bytesToShort/hexStrToStr/hexToBytes/hexToStr/intToByte/intToBytes/
	longToBytes/numberToChinese/numberToWord/shortToBytes/strToUnicode/unicodeToStr/digitToChinese/
操作:convert/convertByClassName/convertCharset/convertQuietly/convertTime/convertWithCheck/unWrap/wrap/
TreeUtil
build/getNode/getParentsName/
ThreadUtil
创建:newCompletionService/newCountDownLatch/newExecutor/newExecutorByBlockingCoefficient/newNamedThreadFactory/
	newSingleExecutor/newThread/createThreadFactoryBuilder/createThreadLocal/
获取:getMainThread/getStackTrace/getStackTraceElement/getThreads/currentThreadGroup/concurrencyTest/
执行:execAsync/execute/safeSleep/sleep/sync/interrupt/
LockUtil
createReadWriteLock/createStampLock/getNoLock/
PageUtil
getEnd/getFirstPageNo/getStart/rainbow/setFirstPageNo/setOneAsFirstPageNo/totalPage/transToStartEnd/
PhoneUtil
hideAfter/hideBefore/hideBetween/isMobile/isPhone/isTel/subAfter/subBefore/subBetween/
RandomUtil-随机工具类
createSecureRandom/getRandom/getSecureRandom/
randomBigDecimal/randomBoolean/randomBytes/randomChar/randomColor/randomDate/randomDay/randomDouble/randomEle/
randomEleList/randomEleSet/randomEles/randomInt/randomInts/randomLong/randomNumber/randomNumbers/randomString/
randomStringUpper/randomStringWithoutStr/randomUUID/simpleUUID/weightRandom/
ReUtil- 正则工具类
contains/count/delAll/delFirst/delPre/escape/extractMulti/extractMultiAndDelPre/isMatch/replaceAll/
findAll/findAllGroup0/findAllGroup1/get/getAllGroups/getFirstNumber/getGroup0/getGroup1/

其他工具类:

FontUtil
createFont/createSansSerifFont/getDimension/
ImgUtil
创建:createFont/createGraphics/createImage/
获取:getColor/getImageInputStream/getImageOutputStream/getPointBaseCentre/getReader/getRectangle/getWriter/
转换:toBase64/toBase64DataUri/toBufferedImage/toBytes/toHex/toImage/toRenderedImage/toStream/hexToColor/
读写:read/write/writeJpg/writePng/
操作:backgroundRemoval/binary/compress/convert/copyImage/cut/flip/gray/
	pressImage/pressText/randomColor/rotate/scale/slice/sliceByRowsAndCols/
GraphicsUtil
createGraphics/drawImg/drawString/drawStringColourful/getCenterY/setAlpha/
NetUtil
获取:getIpByHost/getLocalMacAddress/getLocalhost/getLocalhostStr/getMacAddress/getMultistageReverseProxyIp/
	getNetworkInterface/getNetworkInterfaces/getUsableLocalPort/getUsableLocalPorts/
判断:isInRange/isInnerIP/isOpen/isUnknow/isUnknown/isUsableLocalPort/isValidPort/
获取:localAddressList/localIps/localIpv4s/localIpv6s/longToIpv4/
操作:netCat/parseCookies/ping/toAbsoluteUrl/toIpList/createAddress/hideIpPart/idnToASCII/ipv4ToLong/buildInetSocketAddress/
CsvUtil
getReader/getWriter/
EscapeUtil
escape/escapeAll/escapeHtml4/safeUnescape/unescape/unescapeHtml4/
URLUtil
操作:buildQuery/complateUrl/completeUrl/normalize/url/
	decode/encode/encodeAll/encodeBlank/encodeQuery/toURI/toUrlForHttp/
获取:getContentLength/getDataUri/getDataUriBase64/getDecodedPath/getHost/getJarFile/getPath/getReader/getStream/getURL/getURLs/
判断:isFileURL/isJarFileURL/isJarURL/
CronUtil
getScheduler/remove/restart/schedule/setCronSetting/setMatchSecond/start/stop/updatePattern/
SecureUtil-秘钥工具类
生成秘钥: generateAlgorithm/generateDESKey/generateKey/generateKeyPair/generatePBEKey/
		 generatePrivateKey/generatePublicKey/generateSignature/
读取:readCertificate/readJKSKeyStore/readKeyStore/readX509Certificate/		 
验签:sign/signParams/signParamsMd5/signParamsSha1/signParamsSha256/	
操作: hmac/hmacMd5/hmacSha1/md5/rc4/rsa/sha1/sha256/des/aes/addProvider/simpleUUID/createCipher/createMac/
		createMessageDigest/decode/desede/disableBouncyCastle/getAlgorithmAfterWith/getCertificate/
PinyinUtil
getEngine/getFirstLetter/getPinyin/isChinese/
JSONUtil
判断: isJson/isJsonArray/isJsonObj/isNull/
转换: parse/parseArray/parseFromMap/parseFromResourceBundle/parseFromXml/parseObj/
	toBean/toJsonPrettyStr/toJsonStr/toList/toXmlStr/formatJsonStr/xmlToJson/
读取:	readJSON/readJSONArray/readJSONObject/getByPath/
操作:putByPath/putDeserializer/putSerializer/createArray/createObj/quote/wrap/escape/
SystemUtil-系统信息工具类
获取信息:get/getBoolean/getInt/getLong/getCompilationMXBean/getCurrentPID/
获取本机信息:getHostInfo/getUserInfo/props/dumpSystemInfo/
获取JDK信息:getJavaInfo/getJavaRuntimeInfo/getJavaSpecInfo/
获取虚拟机信息:getJvmInfo/getJvmSpecInfo/getGarbageCollectorMXBeans/
获取内存信息:getMaxMemory/getMemoryMXBean/getMemoryManagerMXBeans/getMemoryPoolMXBeans/getFreeMemory/getTotalMemory/
获取操作系统等信息:getOperatingSystemMXBean/getOsInfo/getRuntimeInfo/getRuntimeMXBean/getThreadMXBean/getTotalThreadCount/

Web工具类

ServletUtil
获取:getBody/getBodyBytes/getClientIP/getClientIPByHeader/getCookie/getHeader/getHeaderIgnoreCase/getHeaderMap/
	 getMultipart/getParamMap/getParams/getWriter/
判断:isGetMethod/isIE/isMultipart/isPostMethod/
操作:readCookieMap/setHeader/toBean/write/fillBean/addCookie/
SpringUtil
getActiveProfile/getActiveProfiles/getApplicationContext/getBean/getBeanNamesForType/
getBeansOfType/getProperty/setApplicationContext/

本地化工具类:

ChineseDate
getChineseDay/getChineseMonth/getChineseMonthName
/getChineseYear/getChineseZodiac/getCyclical/getDay/getFestivals/getMonth/
IdcardUtil
获取:getAgeByIdCard/getBirth/getBirthByIdCard/getBirthDate/getDayByIdCard/getGenderByIdCard/getMonthByIdCard/
	 getProvinceByIdCard/getYearByIdCard/
操作: hide/convert15To18/
判断: isValidCard/isValidCard10/isValidCard15/isValidCard18/isValidHKCard/isValidTWCard/
IdUtil
createSnowflake/fastSimpleUUID/fastUUID/getSnowflake/objectId/randomUUID/simpleUUID/
 类似资料: