java项目常用工具jar包方法整理

Apache-Commons工具包API整理

一、commons-lang3

1、 字符串,数字,日期,数组等工具类

StringUtils 字符串工具类
包含判断方法:contains/containsXXX 
字符串替换方法:replace/replaceXXX 
获取子串:substring/substringXXX 
索引(index):indexOf/indexOfXXX/lastIndexOf/lastIndexOfXXX
判断方法:
1、isEmpty/isNotEmpty/isBlank/isNotBlank/isNumeric/isWhitespace
2、sartsWith/startsWithAny/endsWith/endsWithIgnoreCase
处理方法:
    abbreviate 缩短 capitalise 首字母 repeat 重复 left/right/center 左右中间
    removeXXX 移除 trimXXX 去空  reverseXXX 翻转 stripXXX 移除
    defaultXXX 默认 lowerCase/upperCase deleteXXX 删除处理
    splitXXX分解处理 join 拼接
StringEscapeUtils
CSV处理:escapeCsv/unescapeCsv
HTML处理:escapeHtml/unescapeHtml
java处理:escapeJava/unescapeJava
JavaScript处理:escapeJavaScript/unescapeJavaScript
XML处理:escapeXml/unescapeXml/escapeSql
NumberUtils 数字工具类
创建数字:createXXX  创建Integer,Float,Double,Number,BigDecimal,BigInteger等数字
字符转数字:toXXX     字符串转数字:Byte,Double,Float,Int,Long,Short
判断是否数字:isDigits/isNumber
其他方法:compare,max,min,
ArrayUtils 数组工具类
添加移除:add,addAll,remove,removeElement,
拷贝:clone
判断:contains,isEmpty,isNotEmpty,isEquals,isSameLength,
其他:getLength,indexOf,lastIndexOf,nullToEmpty,reverse,subArray,
转换:toMap,toObject,toPrimitive,toString
RandomUtils 随机数工具类
nextBoolean/nextInt/nextLong/nextFloat/nextDouble
RandomStringUtils 随机字符串工具类
random/randomNumeric/randomAlphabetic/randomAscii
DateUtils 日期工具类
说明:XXX表示milisecends,seconds,minutes,hours,days,weeks,months,years
时间加减:add/addXXX 
时间设置: setXXX 
获取片段: getFragmentInXXX    获取date的1月1日0点0分0秒到指定时间的片段值
判断: isSameDay/isSameInstant/isSameLocalTime
转换: parseDate/parseDateStrictly
取模: ceiling/round/truncate
时间段:iterator   注意rangeStyle=1到4表示周范围以及偏移,5和6表示月偏移
DateFormatUtils时间格式化
格式化:format/formatUTC
DurationFormatUtils时间段格式化
formatDuration/formatDurationHMS/formatDurationISO
formatPeriod/formatPeriodISO
formatDurationWords
StopWatch 秒表
start/stop/suspend/split/resume/reset/unsplit
getSplitTime/getStartTime/getTime/
toSplitString/toString
EnumUtils 枚举工具类
getEnum/getEnumIgnoreCase/getEnumList/getEnumMap
iterator

2、java反射工具类

ClassUtils 类工具
获取: 
    1、类和接口 :getClass/getAllInterfaces/getAllSuperclasses/getShortClassName
    2、包:getPackageName/getPackageCanonicalName
    3、方法:getPublicMethod
转换:
    1、toClass/convertClassesToClassNames/convertClassNamesToClasses/
    2、primitivesToWrappers/primitiveToWrapper/wrappersToPrimitives/wrapperToPrimitive
判断:isAssignable/isInnerClass
MethodUtils
getAccessibleMethod/getMatchingAccessibleMethod
invokeMethod/invokeStaticMethod/invokeExactMethod/invokeExactStaticMethod
FieldUtils 字段工具类
getField/readField/writeField
getDeclaredField/readDeclaredField/writeDeclaredField
readDeclaredStaticField/readStaticField/writeDeclaredStaticField/writeStaticField
ConstructorUtils
getAccessibleConstructor/getMatchingAccessibleConstructor
invokeConstructor/invokeExactConstructor
ObjectUtils 对象工具类
max/min/toString/identityToString/appendIdentityToString/defaultIfNull
SystemUtils 系统属性工具类
getJavaHome/getJavaIoTmpDir/getJavaVersion/getUserDir/getUserHome/
isJavaAwtHeadless/isJavaVersionAtLeast
LocaleUtils 本地工具类
availableLocaleList/availableLocaleSet
countriesByLanguage
localeLookupList/toLocale/isAvailableLocale/languagesByCountry
SerializationUtils 序列化工具类
clone/deserialize/serialize

二、commons-collecions包

CollectionUtils 集合工具类
添加/删除:addAll/addIgnoreNull/retainAll/removeAll/
获取:
	find/get/containsAny/index/size/sizeIsEmpty/select/selectRejected/subtract
	typedCollection
判断: 
	isEmpty/isNotEmpty/isFull/exists/isEqualCollection/
	isSubCollection/isProperSubCollection 
转换: 
	collect/transform/transformedCollection/predicatedCollection
	unmodifiableCollection/synchronizedCollection 
计算:cardinality/countMatches/maxSize
过滤:filter
集合:intersection/union/disjunction  交集,并集,差集
其他操作:
   reverseArray  翻转  forAllDo 给每个元素执行闭包
   getCardinalityMap 转成Map,key是元素,value是次数
ListUtils-List工具类
判断: isEqualList
集合:intersection/sum/union/retainAll 交集,并集,合集,差集
操作:removeAll/hashCodeForList
子集: typedList/subtract/fixedSizeList
转换处理:synchronizedList/unmodifiableList/predicatedList/transformedList/lazyList
SetUtils-Set集合工具类
判断:isEqualSet
转换处理:
		transformedSet/transformedSortedSet/predicatedSet/predicatedSortedSet
		unmodifiableSet/synchronizedSet/synchronizedSortedSet
		orderedSet/typedSet/typedSortedSet
操作:hashCodeForSet
MapUtils-Map工具类
获取:getObject/getString/getXXX/getXXXValue  获取指定类型值,getXXXValue 如果没有值则默认值
子集:fixedSizeMap/fixedSizeSortedMap/typedMap/typedSortedMap
判断:isEmpty/isNotEmpty
转换:
	predicatedMap/predicatedSortedMap/transformedMap/transformedSortedMap/
	synchronizedMap/synchronizedSortedMap/
	unmodifiableMap/unmodifiableSortedMap/multiValueMap/orderedMap
	toMap/toProperties/lazyMap/lazySortedMap
添加移除:safeAddToMap/putAll
其他操作:invertMap/debugPrint/verbosePrint
MultiKey - 为Map定制的多Key
 Map map = new HashMap();
 MultiKey multiKey = new MultiKey(key, locale);
 map.put(multiKey, localizedText);

 // later retireve the localized text
 MultiKey multiKey = new MultiKey(key, locale);
 String localizedText = (String) map.get(multiKey);
 主要方法: getKey,getKeys,size
函数是编程类
// 预处理函数
AllPredicate/AndPredicate/AnyPredicate/UniquePredicate/NonePredicate/IdentityPredicate
EqualPredicate/FalsePredicate/TruePredicate/ExceptionPredicate
NullPredicate/OnePredicate/OrPredicate/InstanceofPredicate
TransformedPredicate/TransformerPredicate/NullIsFalsePredicate/NullIsTruePredicate
NotNullPredicate
NotPredicate
//闭包函数
ChainedClosure/ExceptionClosure/WhileClosure/ForClosure/IfClosure/NOPClosure
TransformerClosure/SwitchClosure/NullIsExceptionPredicate
//转换处理
ChainedTransformer/CloneTransformer/ClosureTransformer/ConstantTransformer
ExceptionTransformer/FactoryTransformer/MapTransformer/InstantiateTransformer
NOPTransformer/PredicateTransformer/StringValueTransformer/SwitchTransformer
InvokerTransformer
//工厂
ConstantFactory/ExceptionFactory/InstantiateFactory/PrototypeFactory

三、commons-io 包

FileUtils 文件操作工具类
文件夹操作: 
 copyDirectory/deleteDirectory/cleanDirectory/getTempDirectory/getTempDirectoryPath
 moveDirectory/moveDirectoryToDirectory/moveFileToDirectory/moveToDirectory
 forceMkdir/getUserDirectory/getUserDirectoryPath
文件操作:
	touch/copyFile/copyURLToFile/moveFile/deleteQuietly/forceDelete/forceDeleteOnExit
	toFile/toFiles/toURLs
	isFileNewer/isFileOlder
	readLines/readFileToByteArray/readFileToString/lineIterator/openOutputStream
	write/writeLines/writeByteArrayToFile/writeStringToFile/openInputStream
其他操作:
    iterateFiles/listFiles/contentEquals/sizeOf/sizeOfDirectory
IOUtils 流操作工具类
读操作:lineIterator/read/readLines
写操作:write/writeLines
转换: toInputStream/toBufferedInputStream/toByteArray/toCharArray/toString
其他操作:copy/copyLarge/contentEquals/skip/skipFully/closeQuietly
FilenameUtils 文件名工具类
获取:
	getName/getBaseName/getPrefix/getPrefixLength/getExtension
	getPath/getFullPath/getFullPathNoEndSeparator/getPathNoEndSeparator
判断:
	isExtension/equals/equalsNormalized/equalsOnSystem
其他操作:
	removeExtension/indexOfExtension
	separatorsToSystem/separatorsToUnix/separatorsToWindows
	indexOfLastSeparator
其他工具类
文件比较器:
    CompositeFileComparator/DefaultFileComparator/DirectoryFileComparator
    ExtensionFileComparator/LastModifiedFileComparator/NameFileComparator
    PathFileComparator/PathFileComparator
文件过滤器:
    AgeFileFilter/AndFileFilter/CanReadFileFilter/CanWriteFileFilter
    DelegateFileFilter/DirectoryFileFilter/EmptyFileFilter/FalseFileFilter/FileFileFilter
    FileFilterUtils/HiddenFileFilter/MagicNumberFileFilter/NameFileFilter/NotFileFilter
    OrFileFilter/PrefixFileFilter/RegexFileFilter/SizeFileFilter/SuffixFileFilter
    TrueFileFilter/WildcardFileFilter/WildcardFilter

四、commons-beanutils包

BeanUtils/BeanUtilsBean
拷贝: cloneBean/copyProperties/copyProperty
获取:getArrayProperty/getSimpleProperty/getProperty
其他操作:setProperty设置属性 populate将Bean设置到Map中  describe将Bean转成Map   
PropertyUtils类
判断:isReadable/isWriteable
获取:
	getProperty/getSimpleProperty/getPropertyType 
	getReadMethod/getWriteMethod/getIndexedProperty/setIndexedProperty
	getMappedProperty/setMappedProperty/getNestedProperty/setNestedProperty  
	getPropertyDescriptor/getPropertyEditorClass
拷贝和设置:copyProperties/setProperty/setSimpleProperty /clearDescriptors       
ConstructorUtils
getAccessibleConstructor/invokeConstructor/invokeExactConstructor 
ConvertUtils
设置:setDefaultBoolean/setDefaultByte/setDefaultCharacter/setDefaultDouble/
	setDefaultFloat/setDefaultInteger/setDefaultLong/setDefaultShort/
获取:getDefaultBoolean/getDefaultByte/getDefaultCharacter/getDefaultDouble/getDefaultFloat/
	getDefaultInteger/getDefaultLong/getDefaultShort/
转换:convert/
其他:deregister/lookup/register/primitiveToWrapper/
MethodUtils
获取:getAccessibleMethod/getMatchingAccessibleMethod/getPrimitiveType/getPrimitiveWrapper
其他:invokeExactMethod/invokeMethod/isAssignmentCompatible/toNonPrimitiveClass

你可能感兴趣的:(java,jar,python)