Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common utility classes for Java code

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "what are the common tool classes for Java code", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn what are the common tool classes for Java code.

1. Org.apache.commons.io.IOUtils

CloseQuietly: closes an IO stream, socket, or or without throwing an exception, usually in a finally block

ToString: convert IO stream, Uri, byte [] to String

Copy:IO stream data replication, which is written from the input stream to the output stream, with maximum support for 2GB

ToByteArray: get byte from input stream, URI []

Write: put bytes. Characters and so on are written to the output stream

ToInputStream: convert characters to input streams

ReadLines: reads multiple lines of data from the input stream and returns List

CopyLarge: same as copy, supports replication of data above 2GB

LineIterator: returns an iterator from the input stream and reads all the data required by the parameter. If there is not enough data, it fails.

II. Org.apache.commons.io.FileUtils

Directory: deleting a folder

ReadFileToString: reading file contents in character form

Queitly: deletes a file or folder without throwing an exception

CopyFile: copying fil

WriteStringToFile: writes characters to the target file, and if the file does not exist, create

ForceMkdir: force the creation of a folder, or create a parent if the folder parent directory does not exist

Write: writes characters to the specified file

ListFiles: enumerates files in a directory (based on filter)

CopyDirectory: copying folder

ForceDelete: force deletion of files

III. Org.apache.commons.lang.StringUtils

IsBlank: whether the string is empty (judged after trim)

IsEmpty: whether the string is empty (do not trim and determine)

Equals: whether strings are equal

Join: merge the array into a single string and pass the delimiter

Split: splitting strin

EMPTY: returns an empty string

Empty string after trimToNull:trim is converted to null

Replace: replacement string

IV. Org.apache.http.util.EntityUtils

ToString: convert Entity to string

Consume: make sure all the content in Entity is consumed. You can see that the content of Entity is consumed again in the source code. If the user does not consume it, it will be consumed when calling Entity.

ToByteArray: converting Entity to byte stream

ConsumeQuietly: same as consume, but no exception thrown

GetContentCharset: gets the encoding of the content.

5. Org.apache.commons.lang3.StringUtils

IsBlank: whether the string is empty (judged after trim)

IsEmpty: whether the string is empty (do not trim and determine)

Equals: whether strings are equal

Join: merge the array into a single string and pass the delimiter

Split: splitting strin

EMPTY: returns an empty string

Replace: replacement string

Capitalize: the first character is capitalized

VI. Org.apache.commons.io.FilenameUtils

GetExtension: returns the file suffix

GetBaseName: returns the file name without the suffix

GetName: returns the full file name

Concat: combine file paths in command line style (see method notes for details)

RemoveExtension: delete suffix name

Normalize: normalize the path

WildcardMatch: matching wildcard characters

SeperatorToUnix: the path delimiter is changed to the unix system format, namely /

GetFullPath: gets the file path, excluding the file name

IsExtension: check whether the file suffix name is one of the passed parameters (List)

7. Org.springframework.util.StringUtils

HasText: check whether the string contains text

HasLength: detects whether the string length is greater than 0

IsEmpty: check whether the string is empty (if passed as an object, determine whether the object is null)

CommaDelimitedStringToArray: comma-separated String converted to an array

CollectionToDelimitedString: converts a collection to a string in CSV format

Replace replacement string

DelimitedListToStringArray: equivalent to split

Uncapitalize: lowercase initials

CollectionToDelimitedCommaString: converts a collection to a string in CSV format

TokenizeToStringArray: basically the same as split, but can automatically remove blank words

VIII. Org.apache.commons.lang.ArrayUtils

Contains: whether to include a string

AddAll: add an entire array

Clone: clone an array

IsEmpty: whether the array is empty

Add: adding elements to an array

Subarray: intercepting array

IndexOf: find the subscript of an element

IsEquals: compare arrays for equality

ToObject: convert the underlying type data array to the corresponding Object array

IX. Org.apache.commons.lang.StringEscapeUtils

10. Org.apache.http.client.utils.URLEncodedUtils

Format: format parameter that returns a HTTP POST or HTTP PUT available application/x-www-form-urlencoded string

Parse: convert String or URI into List

11. Org.apache.commons.codec.digest.DigestUtils

Md5Hex:MD5 encryption that returns a 32-bit string

Sha1Hex:SHA-1 encryption

Sha256Hex:SHA-256 encryption

Sha512Hex:SHA-512 encryption

Md5:MD5 encryption that returns a 16-bit string

12. Org.apache.commons.collections.CollectionUtils

IsEmpty: whether it is empty

Filter collection elements based on criteria

Transform: handles collection elements according to the specified method, similar to List's map ()

Filter: filter element, filter () of Reiser List

Find: basically the same

Collect: almost the same as transform, but returns a new array

ForAllDo: calls the specified method of each element

IsEqualCollection: judge whether two sets are consistent

XIII. Org.apache.commons.lang3.ArrayUtils

Contains: whether to include a string

AddAll: add an entire array

Clone: clone an array

IsEmpty: whether the array is empty

Add: adding elements to an array

Subarray: intercepting array

IndexOf: find the subscript of an element

IsEquals: compare arrays for equality

ToObject: convert the underlying type data array to the corresponding Object array

14. Org.apache.commons.beanutils.PropertyUtils

GetProperty: getting object property valu

SetProperty: setting object property valu

GetPropertyDiscriptor: get property descriptor

IsReadable: check whether the property is accessible

CopyProperties: copy attribute values from one object to another

GetPropertyDiscriptors: get all attribute descriptors

IsWriteable: check whether the property is writable

GetPropertyType: get object attribute type

15. Org.apache.commons.lang3.StringEscapeUtils

UnescapeHtml4: escape html

EscapeHtml4: reverse html

EscapeXml: escape xml

UnescapeXml: reverse xml

EscapeJava: escaping unicode encoding

EscapeEcmaScript: escaping EcmaScript characters

UnescapeJava: reverse unicode encoding

EscapeJson: escaping json characters

EscapeXml10: escape Xml10

This is now obsolete, so it is recommended to use the method in the commons-text package.

16. Org.apache.commons.beanutils.BeanUtils

CopyPeoperties: copy attribute values from one object to another

GetProperty: getting object property valu

SetProperty: setting object property valu

Populate: copy attributes according to Map

CopyPeoperty: copy a single value from one object to another

CloneBean: clone bean instance

These are all the contents of this article entitled "what are the common tool classes for Java code?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report