In Java, a utility class is a class that defines a set of methods that perform a common function.
This article shows the most commonly used Java utility classes and their most commonly used methods. The list of classes and its list of methods are sorted by popularity. The data is based on 50,000 open source Java projects randomly selected from GitHub.
Hopefully, you can browse the list to get an idea of some of the features that are already available and popular, so that you know you don’t need to implement them yourself. The names of these methods usually indicate what they do. If method names aren’t intuitive, you can also see how other developers use them in their open source projects.
org.apache.commons.io.IOUtils
isEmpty()
isNotEmpty()
select()
transform()
filter()
find()
collect()
forAllDo()
addAll()
isEqualCollection()
Copy the code
org.apache.commons.io.FileUtils
deleteDirectory()
readFileToString()
deleteQuietly()
copyFile()
writeStringToFile()
forceMkdir()
write()
listFiles()
copyDirectory()
forceDelete()
Copy the code
org.apache.commons.lang.StringUtils
isBlank()
isNotBlank()
isEmpty()
isNotEmpty()
equals()
join()
split()
EMPTY
trimToNull()
replace()
Copy the code
org.apache.http.util.EntityUtils
toString()
consume()
toByteArray()
consumeQuietly()
getContentCharSet()
Copy the code
org.apache.commons.lang3.StringUtils
isBlank()
isNotBlank()
isEmpty()
isNotEmpty()
join()
equals()
split()
EMPTY
replace()
capitalize()
Copy the code
org.apache.commons.io.FilenameUtils
getExtension()
getBaseName()
getName()
concat()
removeExtension()
normalize()
wildcardMatch()
separatorsToUnix()
getFullPath()
isExtension()
Copy the code
org.springframework.util.StringUtils
hasText()
hasLength()
isEmpty()
commaDelimitedListToStringArray()
collectionToDelimitedString()
replace()
delimitedListToStringArray()
uncapitalize()
collectionToCommaDelimitedString()
tokenizeToStringArray()
Copy the code
org.apache.commons.lang.ArrayUtils
contains()
addAll()
clone()
isEmpty()
add()
EMPTY_BYTE_ARRAY
subarray()
indexOf()
isEquals()
toObject()
Copy the code
org.apache.commons.lang.StringEscapeUtils
escapeHtml()
unescapeHtml()
escapeXml()
escapeSql()
unescapeJava()
escapeJava()
escapeJavaScript()
unescapeXml()
unescapeJavaScript()
Copy the code
org.apache.http.client.utils.URLEncodedUtils
format()
parse()
Copy the code
org.apache.commons.codec.digest.DigestUtils
md5Hex()
shaHex()
sha256Hex()
sha1Hex()
sha()
md5()
sha512Hex()
sha1()
Copy the code
org.apache.commons.collections.CollectionUtils
isEmpty()
isNotEmpty()
select()
transform()
filter()
find()
collect()
forAllDo()
addAll()
isEqualCollection()
Copy the code
org.apache.commons.lang3.ArrayUtils
contains()
isEmpty()
isNotEmpty()
add()
clone()
addAll()
subarray()
indexOf()
EMPTY_OBJECT_ARRAY
EMPTY_STRING_ARRAY
Copy the code
org.apache.commons.beanutils.PropertyUtils
getProperty()
setProperty()
getPropertyDescriptors()
isReadable()
copyProperties()
getPropertyDescriptor()
getSimpleProperty()
isWriteable()
setSimpleProperty()
getPropertyType()
Copy the code
org.apache.commons.lang3.StringEscapeUtils
unescapeHtml4()
escapeHtml4()
escapeXml()
unescapeXml()
escapeJava()
escapeEcmaScript()
unescapeJava()
escapeJson()
escapeXml10()
Copy the code
org.apache.commons.beanutils.BeanUtils
copyProperties()
getProperty()
setProperty()
describe()
populate()
copyProperty()
cloneBean()
Copy the code
hair