In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what kinds of Java tools are commonly used in Java. It is very detailed and has a certain reference value. Friends who are interested must finish it!
one。 Org.apache.commons.io.IOUtils
CloseQuietly: close an IO stream, socket, or selector without throwing an exception, usually put in the finally block toString: convert IO stream, Uri, byte [] to String copy:IO stream data copy, write from input stream to output stream, * support 2GB toByteArray: get byte from input stream, URI: put bytes. Write characters to output stream toInputStream: convert characters to input stream readLines: read multiple lines of data from the input stream and return List
< String >CopyLarge: same as copy, supports replication lineIterator of data above 2GB: returns an iterator from the input stream and reads all the data required by the parameters. If the data is not enough, it fails.
two。 Org.apache.commons.io.FileUtils
DeleteDirectory: delete folder readFileToString: read file contents as characters deleteQueitly: delete a file or folder without throwing an exception copyFile: copy a file writeStringToFile: write characters to the target file, if the file does not exist, create forceMkdir: force the creation of a folder, if the folder parent directory does not exist Then create a parent write: write characters to the specified file listFiles: enumerate files in a directory (according to filter) copyDirectory: copy folder forceDelete: force deletion of files three. Org.apache.commons.lang.StringUtils isBlank: whether the string is empty (determine after trim) isEmpty: whether the string is empty (do not trim and determine) equals: whether the string is equal join: merge the array into a single string, split: split string EMPTY: if the empty string is returned after trimToNull:trim, it is converted to nullreplace: replace the string
three。 Org.apache.commons.lang.StringUtils
IsBlank: whether the string is empty (determine after trim) isEmpty: whether the string is empty (do not trim and determine) equals: whether the string is equal join: merge the array into a single string, split: split string EMPTY: if the empty string is returned after trimToNull:trim, it is converted to null replace: replace the string
four。 Org.apache.http.util.EntityUtils
ToString: convert Entity to string consume: make sure that 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, the call to Entity will consume it toByteArray: convert Entity to byte stream consumeQuietly: same as consume, but no exception getContentCharset: get the encoding of the content
five。 Org.apache.commons.lang3.StringUtils
IsBlank: whether the string is empty (determine after trim) isEmpty: whether the string is empty (do not trim and determine) equals: whether the string is equal join: merge the array into a single string, split: split string EMPTY: return empty string replace: replace string capitalize: first character uppercase
six。 Org.apache.commons.io.FilenameUtils
GetExtension: return file suffix name getBaseName: return file name, excluding suffix name getName: return file full name concat: combine file path according to command line style (see method notes for details) removeExtension: delete suffix name normalize: normalize the path wildcardMatch: match wildcard seperatorToUnix: path separator is changed to unix system format, that is, / getFullPath: get the file path, excluding the file name isExtension: check whether the file suffix name is one of the incoming parameters (List)
seven。 Org.springframework.util.StringUtils
HasText: check whether the string contains text hasLength: detect whether the string length is greater than 0 isEmpty: detect whether the string is empty (if passed as an object, determine whether the object is null) commaDelimitedStringToArray: comma-delimited String into an array collectionToDelimitedString: convert the collection to CSV format string replace replacement string 7. DelimitedListToStringArray: equivalent to split uncapitalize: first letter lowercase collectionToDelimitedCommaString: convert the collection to CSV format string tokenizeToStringArray: basically the same as split But it can automatically remove blank words.
eight。 Org.apache.commons.lang.ArrayUtils
Contains: whether to include a string addAll: add an entire array clone: clone an array isEmpty: whether empty array add: add elements to an array subarray: truncated array indexOf: find the subscript of an element isEquals: compare whether the array is equal toObject: convert the basic type data array to the corresponding Object array
nine。 Org.apache.commons.lang.StringEscapeUtils
Reference 15: org.apache.commons.lang3.StringEscapeUtils
ten。 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: converts String or URI to List
eleven。 Org.apache.commons.codec.digest.DigestUtils
Md5Hex:MD5 encryption, return 32-bit string, sha1Hex:SHA-1 encryption, sha256Hex:SHA-256 encryption, sha512Hex:SHA-512 encryption, md5:MD5 encryption, return 16-bit string
twelve。 Org.apache.commons.collections.CollectionUtils
IsEmpty: empty select: filter collection elements according to conditions transform: handle collection elements according to the specified method, similar to map () filter of List: filter elements, Reiser List's filter () find: basically the same as select collect: almost the same as transform, but return a new array forAllDo: call the specified method of each element isEqualCollection: determine whether the two collections are consistent
thirteen。 Org.apache.commons.lang3.ArrayUtils
Contains: whether to include a string addAll: add an entire array clone: clone an array isEmpty: whether empty array add: add elements to an array subarray: truncated array indexOf: find the subscript of an element isEquals: compare whether the array is equal toObject: convert the basic type data array to the corresponding Object array
fourteen。 Org.apache.commons.beanutils.PropertyUtils
GetProperty: get object property values setProperty: set object property values getPropertyDiscriptor: get property descriptors isReadable: check whether properties are accessible copyProperties: copy property values, from one object to another object getPropertyDiscriptors: get all attribute descriptors isWriteable: check whether attributes are writable getPropertyType: get object property types
fifteen。 Org.apache.commons.lang3.StringEscapeUtils
UnescapeHtml4: escape htmlescapeHtml4: reverse htmlescapeXml: escape xmlunescapeXml: escape xmlescapeJava: escape unicode Encoding escapeEcmaScript: escape EcmaScript character unescapeJava: reverse unicode Encoding escapeJson: escape json character escapeXml10: escape Xml10
This is now obsolete, so it is recommended to use the method in the commons-text package.
sixteen。 Org.apache.commons.beanutils.BeanUtils
CopyPeoperties: copy attribute values, from one object to another getProperty: get object attribute values setProperty: set object attribute values populate: copy copyPeoperty to attributes according to Map: copy a single value, from one object to another object cloneBean: clone bean instance now as long as you know the above 16 tool class methods, you no longer need to write your own tool class, do not have to repeat the wheel. Most utility methods can understand their purpose by their name, if not, you can take a look at how others use it, or check its usage online. In addition, the tool class, according to Ali development manual, the package name if you want to use util can not take s, the tool class is named XxxUtils. These are all the contents of this article entitled "what are the Java tool classes commonly used in Java?" Thank you for reading! Hope to share the content to help you, more related 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.