当前位置:网站首页>Hutool Usage Summary (VIP collection version)
Hutool Usage Summary (VIP collection version)
2022-06-10 15:06:00 【Java Tony】
Catalog
Two 、 Design philosophy and advantages
Detailed description of component package
BigDecimal Addition, subtraction, multiplication and division
The configuration file (Hutool-setting)
Encryption and decryption (Hutool-crypto)
Office The document operation (Hutool-poi)
Graphic verification code (Hutool-captcha)
The Internet Socket(Hutool-socket)
One 、 brief introduction
Hutool It's a small and complete Java Tool library , Encapsulate... In a static way , Reduce the correlation API Cost of learning , Improve work efficiency , send Java With the elegance of functional language , Give Way Java Language can also “ Sweet ”.
Hutool The tools and methods in are refined by each user , It covers Java Develop all aspects of the underlying code , It is a sharp tool to solve small problems in large-scale project development , It is also the efficiency responsibility in small projects ;
- Web Development
- No coupling with other frames
- Height replaceable
Two 、 Design philosophy and advantages
Design philosophy
Hutool The design idea is to minimize repetitive definitions , Let the util This package As far as possible , In general, there are the following ideas :
- Method takes precedence over object
- Automatic recognition is better than user-defined
- Convenience and flexibility coexist
- Adaptation and compatibility
- The optional dependency principle
- No invasion principle
advantage
Other tools follow Huttol comparison , What are the shortcomings? :
- Apache Family bucket : English annotation , Method needs to be checked
- Guava:Jar Big bag ,API Awkward
- Jodd: And Hutool Most similar , Incomplete functions
- Nutz: Tools and methods are very easy to use , But it's a framework
- Voovan: Tools and methods are very easy to use , It's solved IO Questions first , The application scenario is not wide
3、 ... and 、 install
Maven Quoted total quantity
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.2</version> </dependency>Maven On-demand reference
For example, quote hutool-aop
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-aop</artifactId> <version>5.8.2</version> </dependency>Gradle quote
implementation 'cn.hutool:hutool-all:5.8.2'Four 、 Components
Component package description
One Java Basic tools , The file 、 flow 、 Encryption and decryption 、 transcoding 、 Regular 、 Threads 、XML etc. JDK Method to encapsulate , Make up all kinds of Util Tool class , The following components are also provided :
modular Introduce hutool-aop JDK Dynamic agent encapsulation , Provide non IOC Next aspect support hutool-bloomFilter Bloon filtration , Provide some Hash Algorithm's bloom filtering hutool-cache Simple cache implementation hutool-core The core , Include Bean operation 、 date 、 Various Util etc. hutool-cron Timing task module , Provide classes Crontab Expression timing task hutool-crypto Encryption and decryption module , Provide symmetry 、 Asymmetric and digest algorithm encapsulation hutool-db JDBC Data operation after encapsulation , be based on ActiveRecord thought hutool-dfa be based on DFA Multi keyword search of model hutool-extra Extension module , Encapsulate... To a third party ( template engine 、 mail 、Servlet、 QR code 、Emoji、FTP、 Participle, etc ) hutool-http be based on HttpUrlConnection Of Http Client encapsulation hutool-log Automatic recognition of the log door hutool-script Script execution encapsulation , for example Javascript hutool-setting More powerful Setting Configuration files and Properties encapsulation hutool-system System parameter call encapsulation (JVM Information, etc ) hutool-json JSON Realization hutool-captcha Picture verification code implementation hutool-poi in the light of POI in Excel and Word Encapsulation hutool-socket be based on Java Of NIO and AIO Of Socket encapsulation hutool-jwt JSON Web Token (JWT) Encapsulation implementation Each module can be introduced separately according to the requirements , Or by introducing
hutool-allWay to introduce all modules .Detailed description of component package
Package Description cn.hutool Hutool It's a small and complete Java Tool library , Encapsulate... In a static way , Reduce the correlation API Cost of learning , Improve work efficiency , send Java With the elegance of functional language , Give Way Java Language can also “ Sweet ”. cn.hutool.aop JDK Dynamic agent encapsulation , Provide non IOC Next aspect support cn.hutool.aop.aspects Cut to achieve , Provide some basic facet implementations cn.hutool.aop.interceptor Proxy interceptor implementation cn.hutool.aop.proxy The proxy implementation cn.hutool.bloomfilter Bloon filtration , Provide some Hash Algorithm's bloom filtering cn.hutool.bloomfilter.bitMap BitMap Realization cn.hutool.bloomfilter.filter Various Hash Filter implementation of the algorithm cn.hutool.cache Provide a simple cache implementation , This module refers to jodd Tools Cache modular cn.hutool.cache.file Provide cache implementation for files cn.hutool.cache.impl Provide various cache implementations cn.hutool.captcha Picture verification code implementation cn.hutool.captcha.generator Verification code generation strategy implementation cn.hutool.core Hutool Core method and data structure package cn.hutool.core.annotation Annotation package , Provides enhanced annotations and annotation tool classes cn.hutool.core.bean Bean The relevant operation , Include Bean Information description ,Bean Path expression 、 dynamic Bean、Bean Tools etc. cn.hutool.core.bean.copier Bean Copy implementation , Including copy options, etc cn.hutool.core.bean.copier.provider Bean Value provider mode encapsulation cn.hutool.core.builder Builder tools Used to construct specific objects or results cn.hutool.core.clone Cloning encapsulates cn.hutool.core.codec BaseN as well as BCD Coding encapsulation cn.hutool.core.collection Assemble and Iterator encapsulation , Including collection tools CollUtil,Iterator and Iterable Tools IterUtil cn.hutool.core.comparator Various comparators (Comparator) Implementation and encapsulation cn.hutool.core.compiler Compile at run time java Source code , Dynamically load classes from strings or external files cn.hutool.core.compress Compress, decompress and package cn.hutool.core.convert Universal type converter and implementation classes of various type conversions , among Convert Is the converter inlet , Provide all kinds of toXXX Methods and convert Method cn.hutool.core.convert.impl Implementation classes for various types of transformations , They are all Converter Interface implementation , Used to put unknown Object The type is converted to the specified type cn.hutool.core.date Date encapsulation , The core of the date is DateTime class ,DateUtil Provide entry for date operation cn.hutool.core.date.chinese Summary of lunar calendar related categories , Including the lunar month 、 Heaven and earth 、 Lunar Festival 、24 Solar terms, etc cn.hutool.core.date.format Provide thread safe date format formatting and parsing implementation cn.hutool.core.exceptions Special exception encapsulation , Also provide exception tools ExceptionUtil cn.hutool.core.getter getXXX Method interface and abstract implementation cn.hutool.core.img Image processing related tool class encapsulation cn.hutool.core.img.gif GIF Handle , come from :https://github.com/rtyley/animated-gif-lib-for-java cn.hutool.core.io IO Related encapsulation and tool classes , Include Inputstream and OutputStream Implementation class , Tools include flow tools IoUtil、 File tools FileUtil and Buffer Tools BufferUtil cn.hutool.core.io.checksum IO Verify related libraries and tools cn.hutool.core.io.checksum.crc16 CRC16 The related algorithms are encapsulated as Checksum cn.hutool.core.io.copy IO Stream copy related encapsulation related encapsulation cn.hutool.core.io.file Encapsulation of file read / write , Include file copies 、 File read 、 The document says 、 Line processing, etc cn.hutool.core.io.file.visitor FileVisitor Functional implementation , Including recursive deletion 、 Copy, etc cn.hutool.core.io.resource in the light of ClassPath And the encapsulation of resource reading in the file , The main entry is tools ResourceUtil cn.hutool.core.io.unit Data unit related encapsulation , Include DataUnit Data units and DataSize data size cn.hutool.core.io.watch be based on JDK7+ WatchService File and directory listening encapsulation , Support multi-level directory cn.hutool.core.io.watch.watchers Observer implementation class in file listener , Including deferred processing 、 Processing chain, etc cn.hutool.core.lang Language Feature Pack , Including a large number of convenient data structures , For example, verifiers Validator, Distributed ID generator Snowflake etc. cn.hutool.core.lang.ansi Command line terminal ANSI Escape sequence related encapsulation , Such as ANSI Color, etc. cn.hutool.core.lang.caller Caller interface and implementation . The caller can be obtained through this method 、 Multi level caller and judge whether it is called cn.hutool.core.lang.copier Copy Abstract implementation , Through abstract copy , Can implement file 、 flow 、Buffer Copy between cn.hutool.core.lang.func Function encapsulation The interface is inspired by ActFramework A function interface represents a function , Used to wrap a function as an object stay JDK8 Before ,Java A function of cannot be passed as a parameter , Nor can it exist as a return value , This interface is used to wrap a function into an object , So as to pass the object cn.hutool.core.lang.generator Provide generator interface and related packages cn.hutool.core.lang.hash Provide Hash Encapsulation of algorithms cn.hutool.core.lang.id Provide all kinds of ID Generate cn.hutool.core.lang.intern The canonical representation encapsulates So called normalization , That is, when two objects equals when , Normalized objects can implement == The related encapsulation in this package is similar to String#intern() cn.hutool.core.lang.loader The abstract interface and implementation of loader , Including the implementation of lazy loading cn.hutool.core.lang.mutable Provides encapsulation of variable value objects , For encapsulation int、long Equal immutable value , Make it variable cn.hutool.core.lang.reflect Provide reflection related function objects and classes cn.hutool.core.lang.tree Provide generic tree generation , characteristic : cn.hutool.core.lang.tree.parser cn.hutool.core.map Map Related packaging , Provide special Map Realize and Map Tools MapUtil cn.hutool.core.map.multi Multi parameter type Map Realization , Include values of the collection type Map and Table cn.hutool.core.math Provide mathematical calculation related packages , Including arrangement and combination , The entrance is MathUtil cn.hutool.core.net Network related tools cn.hutool.core.net.multipart File upload package cn.hutool.core.net.url URL Related tools cn.hutool.core.stream Java8 Of stream Related packaging cn.hutool.core.swing Swing and awt Related packaging cn.hutool.core.swing.clipboard Clipboard related tools , Including clipboard monitoring cn.hutool.core.text Provides encapsulation of text related operations , It also includes Unicode Tools UnicodeUtil cn.hutool.core.text.csv Provide CSV File read / write encapsulation , The entrance is CsvUtil See :https://datatracker.ietf.org/doc/html/rfc4180 cn.hutool.core.text.escape Provides various escape and anti escape implementations cn.hutool.core.text.finder Text search implementation , Include : Find characters in text ( positive 、 reverse ) Find matching characters in text ( positive 、 reverse ) Find the string in the text ( positive 、 reverse ) Find the regular string in the text ( positive ) cn.hutool.core.text.replacer Text replacement class abstraction and implementation cn.hutool.core.text.split cn.hutool.core.thread Provide threading and high concurrency encapsulation , The entrance is ThreadUtil cn.hutool.core.thread.lock Lock implementation cn.hutool.core.thread.threadlocal ThreadLocal Related packaging cn.hutool.core.util Provide various tools and methods , According to the classification, the entrance is XXXUtil, Such as string tools StrUtil etc. cn.hutool.cron Timing task module , Provide classes Crontab Expression timing task , Implementation reference Cron4j, At the same time, it can support the definition of second level scheduled tasks and year ( Compatible with Crontab、Cron4j、Quartz expression ) The timing task module consists of three parts : Scheduler Timed task scheduler , It is used for adding and deleting overall management tasks 、 Start stop and trigger operation . Task Timed task implementation , Used to define specific tasks CronPattern Timed task expression , Used to define task trigger time meanwhile , Provides CronUtil Tool class , Maintain a global Scheduler. cn.hutool.cron.listener Timed task execution monitoring interface and its partial implementation cn.hutool.cron.pattern Timed task expression parsing , The core is CronPattern cn.hutool.cron.pattern.matcher Timed task expression matcher , For internal use A single expression uses PatternMatcher Express PatternMatcher from 7 individual PartMatcher form , Respectively represent... In the timed task expression 7 A place : cn.hutool.cron.pattern.parser Timed task expression parser , For internal use cn.hutool.cron.task Abstract encapsulation and implementation of jobs in scheduled tasks , Include Runnable Implementation and reflection implementation Task Represents a specific task , When the time matching requirements are met , Will execute Task.execute() Method . cn.hutool.cron.timingwheel Time wheel implementation , Rewrote kafka Of TimingWheel The time wheel is usually realized as a ring structure , Like a clock , Divided into many slots , A slot represents a time interval , Each slot uses a two-way linked list to store scheduled tasks . The pointer beats periodically , Jump to a slot , Execute the timing task of the slot . cn.hutool.crypto Encryption and decryption module , Realized with JDK The encapsulation of encryption and decryption algorithm in , The entrance is SecureUtil, Realized : cn.hutool.crypto.asymmetric Implementation of asymmetric encryption , Include RSA etc. cn.hutool.crypto.digest Implementation of encryption algorithm , The entrance is DigestUtil cn.hutool.crypto.digest.mac HMAC, Its full name is “Hash Message Authentication Code”, Chinese name “ Hash message identifier ” Hash algorithm is mainly used , Take a key and a message as input , Generate a message digest as output . General , The message authentication code is used to verify that the message is transmitted in two common Messages between units that share a key . HMAC It can be used in conjunction with any iterative hash function .MD5 and SHA-1 This is the hash function .HMAC You can also use a key to calculate and confirm the message authentication value . cn.hutool.crypto.digest.otp OTP yes One-Time Password Abbreviation , Indicates a one-time password . cn.hutool.crypto.symmetric Implementation of symmetric encryption algorithm , Include AES、DES、DESede etc. cn.hutool.crypto.symmetric.fpe cn.hutool.db Hutool-db It's a JDBC Database operation tool class encapsulated on the basis of , By packing , Use ActiveRecord Think about operating the database . stay Hutool-db in , Use Entity( It's essentially a Map) Instead of Bean Make database operation more flexible , At the same time provide Bean and Entity The transformation of provides traditional ORM Compatible support for . cn.hutool.db.dialect Database dialect encapsulation , Including database dialect and dialect automatic recognition cn.hutool.db.dialect.impl Database dialect implementation , Include MySQL、Oracle、PostgreSQL、Sqlite3、H2、SqlServer2012 etc. cn.hutool.db.ds Data source encapsulation , Encapsulation of various database connection pools cn.hutool.db.ds.bee BeeCP encapsulation see :https://github.com/Chris2018998/BeeCP cn.hutool.db.ds.c3p0 C3P0 encapsulation cn.hutool.db.ds.dbcp DBCP encapsulation cn.hutool.db.ds.druid Druid encapsulation cn.hutool.db.ds.hikari Hikari encapsulation cn.hutool.db.ds.jndi JNDI encapsulation cn.hutool.db.ds.pooled Hutool Simple implementation of connection pool cn.hutool.db.ds.simple JDBC in DriverManager Easy to package cn.hutool.db.ds.tomcat Tomcat-Pool encapsulation cn.hutool.db.handler JDBC Result set (ResultSet) Conversion encapsulation , By implementing RsHandler Interface , take ResultSet Convert to the data type we want cn.hutool.db.meta JDBC Data table metadata information encapsulation , Including table structure 、 Encapsulation of column information , The entrance is MetaUtil cn.hutool.db.nosql NoSQL encapsulation , Include Redis and MongoDB And so on cn.hutool.db.nosql.mongo MongoDB Encapsulation of database operations cn.hutool.db.nosql.redis Redis(Jedis) Encapsulation of database operations cn.hutool.db.sql SQL Statement and Statement Build encapsulation cn.hutool.db.transaction Transaction related classes and operations cn.hutool.dfa DFA Its full name is :Deterministic Finite Automaton, That is, to be sure that there is a finite automaton . It's not hard to explain the principle , It is to construct a tree with all the keywords , And then walk through the tree with the text , Traversing to the leaf node means that the keyword exists in the article . Let's ignore the time to build the keyword tree , Every time you look up the text, you just need to O(n) The complexity can be done . cn.hutool.extra because Hutool The principle is not to rely on other configuration files , But most of the time, we need to do some tool classification support for the third-party libraries , therefore Hutoo-extra Package is mainly used to support tool class support of third-party libraries . cn.hutool.extra.cglib Cglib Library method encapsulation cn.hutool.extra.compress be based on commons-compress Compression and decompression package Support includes :gzip, bzip2, xz, lzma, Pack200, DEFLATE, Brotli, DEFLATE64, ZStandard and Z, the archiver formats are 7z, ar, arj, cpio, dump, tar and zip Equiform . cn.hutool.extra.compress.archiver be based on commons-compress The packaging ( Compress ) encapsulation cn.hutool.extra.compress.extractor be based on commons-compress Unpacking ( decompression ) encapsulation cn.hutool.extra.emoji be based on https://github.com/vdurmont/emoji-java Of Emoji Expression tools cn.hutool.extra.expression Expression language engine encapsulation cn.hutool.extra.expression.engine Expression language engine encapsulation cn.hutool.extra.expression.engine.aviator Aviator Engine encapsulation , see :https://github.com/killme2008/aviatorscript cn.hutool.extra.expression.engine.jexl Jexl3 Engine encapsulation , see :https://github.com/apache/commons-jexl cn.hutool.extra.expression.engine.jfireel JfireEL Engine encapsulation see :https://gitee.com/eric_ds/jfireEL cn.hutool.extra.expression.engine.mvel MVEL (MVFLEX Expression Language) Engine encapsulation see :https://github.com/mvel/mvel cn.hutool.extra.expression.engine.rhino rhino Engine encapsulation see :https://github.com/mozilla/rhino cn.hutool.extra.expression.engine.spel Spring-Expression Engine encapsulation see :https://github.com/spring-projects/spring-framework/tree/master/spring-expression cn.hutool.extra.ftp be based on Apache Commons Net Packaged FTP Tools cn.hutool.extra.mail Email encapsulation , be based on javax-mail library , The entrance is MailUtil cn.hutool.extra.pinyin Phonetic tool encapsulation , The entrance is PinyinUtil cn.hutool.extra.pinyin.engine Pinyin concrete implementation cn.hutool.extra.pinyin.engine.bopomofo4j Encapsulates the Bopomofo4j The engine of . cn.hutool.extra.pinyin.engine.houbbpinyin Encapsulates the Pinyin The engine of . cn.hutool.extra.pinyin.engine.jpinyin Encapsulates the Jpinyin The engine of . cn.hutool.extra.pinyin.engine.pinyin4j Encapsulates the Pinyin4j The engine of . cn.hutool.extra.pinyin.engine.tinypinyin Encapsulates the TinyPinyin The engine of . cn.hutool.extra.qrcode QR code encapsulation , be based on zxing library , The entrance is QrCodeUtil cn.hutool.extra.servlet Servlet encapsulation , Include Servlet Parameters to obtain 、 Upload files 、Response Write etc , The entrance is ServletUtil cn.hutool.extra.spring Spring Related tool encapsulation cn.hutool.extra.ssh Jsch encapsulation , Including port mapping 、SFTP Package, etc , The entrance is JschUtil cn.hutool.extra.template Third party template engine encapsulation , Provide a unified interface for adapting to the third-party template engine cn.hutool.extra.template.engine Third party template engine implementation cn.hutool.extra.template.engine.beetl Beetl Realization , For an introduction to the template engine, see :http://ibeetl.com/ cn.hutool.extra.template.engine.enjoy Jfinal Family Enjoy Template Engine Implementation , see :https://jfinal.com/doc/6-1 cn.hutool.extra.template.engine.freemarker Freemarker Realization see :https://freemarker.apache.org/ cn.hutool.extra.template.engine.jetbrick jetbrick-template Realization , For an introduction to the template engine, see :https://github.com/subchen/jetbrick-template-2x cn.hutool.extra.template.engine.jetbrick.loader jetbrick-template Realization , Special resource loader For an introduction to the template engine, see :https://github.com/subchen/jetbrick-template-2x cn.hutool.extra.template.engine.rythm Rythm Realization , see :http://www.rythmengine.org/ cn.hutool.extra.template.engine.thymeleaf Thymeleaf Realization , see :https://www.thymeleaf.org/ cn.hutool.extra.template.engine.velocity Velocity Realization see :http://velocity.apache.org/ cn.hutool.extra.template.engine.wit Wit Realization , see :http://zqq90.github.io/webit-script/ cn.hutool.extra.tokenizer Chinese word segmentation By defining a unified interface , Adapt to the third-party word segmentation engine cn.hutool.extra.tokenizer.engine Third party word segmentation engine implementation cn.hutool.extra.tokenizer.engine.analysis Lucene-analysis Word segmentation Abstract encapsulation Project address :https://github.com/apache/lucene-solr/tree/master/lucene/analysis cn.hutool.extra.tokenizer.engine.ansj Ansj Participle implementation Project address :https://github.com/NLPchina/ansj_seg cn.hutool.extra.tokenizer.engine.hanlp HanLP Word segmentation engine implementation Project address :https://github.com/hankcs/HanLP cn.hutool.extra.tokenizer.engine.ikanalyzer IKAnalyzer Word segmentation engine implementation Project address :https://github.com/yozhao/IKAnalyzer cn.hutool.extra.tokenizer.engine.jcseg Jcseg Word segmentation engine implementation Project address :https://gitee.com/lionsoul/jcseg cn.hutool.extra.tokenizer.engine.jieba Jieba Word segmentation engine implementation Project address :https://github.com/huaban/jieba-analysis cn.hutool.extra.tokenizer.engine.mmseg mmseg4j Word segmentation engine implementation Project address :https://github.com/chenlb/mmseg4j-core cn.hutool.extra.tokenizer.engine.mynlp MYNLP chinese NLP Toolkit word segmentation implementation Project address :https://github.com/mayabot/mynlp/ cn.hutool.extra.tokenizer.engine.word Word Word segmentation engine implementation Project address :https://github.com/ysc/word cn.hutool.extra.validation be based on JSR-380 Standard calibration tool class , Encapsulates the javax.validation Of API cn.hutool.http Hutool-http in the light of JDK Of HttpUrlConnection Make a layer of packaging , To simplify the HTTPS request 、 Upload files 、Cookie Memory and other operations , send Http The request becomes extremely simple . cn.hutool.http.body The request body encapsulates the implementation cn.hutool.http.cookie Customize Cookie cn.hutool.http.server Http Server encapsulation cn.hutool.http.server.action HttpServer encapsulation cn.hutool.http.server.filter Filter Realize packaging cn.hutool.http.server.handler HttpHandler Realize packaging cn.hutool.http.ssl SSL encapsulation cn.hutool.http.useragent User-Agent analysis cn.hutool.http.webservice Webservice Client encapsulation implementation cn.hutool.json JSON encapsulation , be based on json.org Official library transformation cn.hutool.json.serialize JSON Custom serialization and deserialization interfaces and default implementations cn.hutool.json.xml JSON And XML Mutual conversion encapsulation , be based on json.org Official library transformation cn.hutool.jwt JSON Web Token (JWT) encapsulation cn.hutool.jwt.signers JWT Signature encapsulation cn.hutool.log Hutool-log It's just a general facade for logs , Function like Slf4j. Join according to ClassPath Medium jar The implementation of packet dynamic detection log , Make the log more convenient and flexible . cn.hutool.log.dialect Implementation encapsulation of the third-party log library cn.hutool.log.dialect.commons Apache-Commons-Logging The implementation of the log base is encapsulated cn.hutool.log.dialect.console Implementation encapsulation of console output cn.hutool.log.dialect.jboss jboss-logging Realization cn.hutool.log.dialect.jdk JDK-Logging Implementation encapsulation of cn.hutool.log.dialect.log4j Log4j Implementation encapsulation of cn.hutool.log.dialect.log4j2 Log4j2 Implementation encapsulation of cn.hutool.log.dialect.logtube LogTube Implementation encapsulation of cn.hutool.log.dialect.slf4j Slf4j Implementation encapsulation of cn.hutool.log.dialect.tinylog tinylog Implementation encapsulation of Packaging includes TinyLog and TinyLog2 cn.hutool.log.level Log print interface definitions defined by log level cn.hutool.poi POI Encapsulation implementation Java in the light of MS Office There are only a few libraries of operations , The more famous one is Apache Of POI library . This library is extremely powerful , But it's not easy to use .Hutool in the light of POI Encapsulate some common tools , send Java operation Excel Wait until the file becomes extremely simple . cn.hutool.poi.excel POI Chinese vs Excel Read write encapsulation , The entrance is ExcelUtil cn.hutool.poi.excel.cell Excel Cell related classes in , The entrance is CellUtil cn.hutool.poi.excel.cell.setters Excel Set related classes in the cells in the , some CellSetter Implementation class of cn.hutool.poi.excel.cell.values cn.hutool.poi.excel.editors Cell value editor , For internal use cn.hutool.poi.excel.reader Data reading interface and its implementation , This package defines SheetReader, Through the implementation of this interface , Realization sheet The data in is read as different types . cn.hutool.poi.excel.sax Sax Way to operate Excel Way of encapsulation cn.hutool.poi.excel.sax.handler Sax Read the definition and implementation of BOC processor cn.hutool.poi.excel.style Excel Style encapsulation , The entrance is :StyleUtil cn.hutool.poi.exceptions POI Related anomalies cn.hutool.poi.ofd Open layout document (Open Fixed-layout Document ) encapsulation , be based on ofdrw(https://gitee.com/Trisia/ofdrw) cn.hutool.poi.word POI Chinese vs Word Operation package cn.hutool.script Script The module is mainly for Java Of javax.script encapsulation , Can run Javascript Script . cn.hutool.setting Setting The module is mainly for Properties File read / write encapsulation , At the same time, define a set of configuration file specifications , Achieve a well compatible configuration tool . cn.hutool.setting.dialect The configuration file implements encapsulation , for example Properties encapsulation Props cn.hutool.setting.profile Configure environment encapsulation , for example Profile You can customize the location of configuration files in different environments cn.hutool.setting.yaml YAML Read write encapsulation of files , be based on snakeyaml cn.hutool.socket Socket Socket related tool class encapsulation cn.hutool.socket.aio AIO Related packaging cn.hutool.socket.nio NIO Related packaging cn.hutool.socket.protocol Message protocol interface and its implementation cn.hutool.system System The module mainly obtains the system 、JVM、 Memory 、CPU Etc , In order to dynamically monitor the system status cn.hutool.system.oshi Oshi Library encapsulation https://github.com/oshi/oshi 5、 ... and 、 Code using
String related
/** * String related */ @Test public void test1() { int a = 1; String a1 = Convert.toStr(a); System.out.println(a1); long[] b = {1,2,3,4,5}; String b1 = Convert.toStr(b); System.out.println(b1); String str = " You can't see the Yellow River coming up , Running to the sea and never returning "; // Use of string formatting System.out.println(StrUtil.format(" String content :{}", str)); // Determines if the string is empty System.out.println(" Whether the string is empty :" + StrUtil.isEmpty(str)); // Original usage System.out.println(" Whether the string is empty 2:" + StringUtils.isEmpty(str)); System.out.println(" Whether the string is empty 3:" + StringUtils.isBlank(str)); }
BigDecimal Addition, subtraction, multiplication and division
/** * BigDecimal Addition, subtraction, multiplication and division * * @author libusi */ @Test public void test2() { BigDecimal b1 = new BigDecimal("8.256"); BigDecimal b2 = new BigDecimal("6.347"); // Add BigDecimal addResult = NumberUtil.add(b1, b2); System.out.println(" Addition result :" + addResult); // Subtraction BigDecimal subResult = NumberUtil.sub(b1, b2); System.out.println(" Subtraction results :" + subResult); // Multiplication BigDecimal mulResult = NumberUtil.mul(b1, b2); System.out.println(" The result of multiplication :" + mulResult); // division BigDecimal divResult = NumberUtil.div(b1, b2); System.out.println(" Division result :" + divResult); // Keep two decimal places BigDecimal roundResult = NumberUtil.round(b1, 2); System.out.println(" Keep two decimal places :" + roundResult); }
Time tools (hutool-core)
The date and time package is Hutool One of the core packages of , Provide targeted JDK in Date and Calendar Encapsulation of objects
IO Stream correlationio Package packaging is mainly aimed at convection 、 Read write encapsulation of files , It's mainly about tools , Provides encapsulation of common functions
Common toolsThe tool classes in this package are unclassified , Provide some common tools and methods .
This package is classified as XXXUtil, Provide a large number of tools and methods . In a tool class , Mainly by class method (static Method ) Mainly , And each class cannot be instantiated as an object , A method is an independent function , No interaction .
Linguistic characteristicsLinguistic characteristics , namely lang package , Mainly aimed at JDK The perfection of some data structures and interfaces in
JavaBeanin the light of JavaBean There has been a BeanUtil Tool encapsulation , And extended .
Collection classesThe collection package includes Enumeration、Iterator And so on
MapEarliest Map The related tools are included in CollUtil Medium , But considering that Map And set are not the same kind of data structure , So stand alone , And Hutool Encapsulates many custom Map class , Therefore, it is packed separately .
Codec codecode Code and decode , contain Base62,Base64 and Base32 And so on .
Text operationContains the CSV File processing tools , Reusable string generator ,Unicode Code conversion tools and string cutting tools
annotationTool classes that encapsulate methods such as annotation acquisition
The comparatorVarious comparators (Comparator) Implementation and encapsulation
abnormalEncapsulate for exceptions , For example, the package is RuntimeException
mathematicsThis tool is NumberUtil A supplement to ,NumberUtil Packaging that favors simple mathematical calculations ,MathUtil Biased towards complex mathematical calculations
picturePicture tools and picture editors
The InternetWeb tools and URL generator
The configuration file (Hutool-setting)Setting In addition to compatibility Properties Out of file format , It also provides some unique features , These functions include :
Various encoding methods support
Variables support
Group support
journal (Hutool-log)Accurately speaking ,Hutool-log It's just a general facade for logs , Function like Slf4j
cache (Hutool-cache)Hutool-cache The module was first jodd-cache Inspired by the ( Most of the logic today is still related to jodd bring into correspondence with ), This module provides a simple implementation of caching , Very useful for simple caching requirements in small projects .
JSON(Hutool-json)Undeniable? , Now excellent JSON There are so many frames , I often use something like Ali's FastJSON,Jackson And so on are all excellent bags , Outstanding performance , Simple and easy to use .Hutool At first, I didn't want to write one by myself JSON, But in the encapsulation of various tools , Find out JSON Already indispensable , So it will json.org Official JSON Analysis is included in it , To transform . In the process of transformation , Actively absorb the advantages of other class libraries , Optimize member methods , Abstract interfaces and classes , To form Hutool-json.
Encryption and decryption (Hutool-crypto)There are three kinds of encryption :
Symmetric encryption (symmetric), for example :AES、DES etc.
Asymmetric encryption (asymmetric), for example :RSA、DSA etc.
Abstract encryption (digest), for example :MD5、SHA-1、SHA-256、HMAC etc.
hutool-crypto These three encryption types are encapsulated separately , And provide most commonly used encryption algorithms .package com.god.demo.utils; import cn.hutool.core.codec.Base64; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.RSA; import cn.hutool.crypto.digest.DigestAlgorithm; import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.crypto.digest.Digester; import cn.hutool.crypto.symmetric.AES; import cn.hutool.crypto.symmetric.SymmetricAlgorithm; import cn.hutool.crypto.symmetric.SymmetricCrypto; import org.junit.jupiter.api.Test; public class SmTest { /** * md5 encryption */ @Test public void test2() { String content = " You don't see yellow SecureUtil The water of the river comes up from the sky , Running to the sea and never returning "; String encrypt = SecureUtil.md5(content); System.out.println(" Content before encryption :" + content); System.out.println(" Encrypted content :" + encrypt); } // Abstract encryption algorithm @Test public void fun1() { // Get a summary //MD5 String content = " You don't see yellow SecureUtil The water of the river comes up from the sky , Running to the sea and never returning "; String encrypt = SecureUtil.md5(content); System.out.println(" Content before encryption :" + content); System.out.println(" Encrypted content :" + encrypt); // Mode one Digester md5 = new Digester(DigestAlgorithm.MD5); String str = md5.digestHex(content); System.out.println(str); // Mode two String string = DigestUtil.md5Hex(content); System.out.println(string); } // Asymmetric encryption @Test public void fun2() { // Asymmetric encryption RSA rsa = new RSA(); // Get private key rsa.getPrivateKey(); rsa.getPrivateKeyBase64(); // Get the public key rsa.getPublicKey(); rsa.getPublicKeyBase64(); // Public key encryption , Private key encryption byte[] encrypt = rsa.encrypt(StrUtil.bytes("RAS test ", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey); byte[] decrypt = rsa.decrypt(encrypt, KeyType.PrivateKey); String encode = Base64.encode(decrypt); System.out.println(encode); // Private key encryption , Public key decryption byte[] encrypt2 = rsa.encrypt(StrUtil.bytes("RAS test ", CharsetUtil.CHARSET_UTF_8), KeyType.PrivateKey); byte[] decrypt2 = rsa.decrypt(encrypt2, KeyType.PublicKey); String encode2 = Base64.encode(decrypt2); System.out.println(encode2); } @Test public void fun4() { String content = "asdf1234"; byte[] key = "hahaaha".getBytes(); // structure SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key); // encryption byte[] encrypt = aes.encrypt(content); // Decrypt byte[] decrypt = aes.decrypt(encrypt); } // Symmetric encryption @Test public void fun3() { // The first one is : With AES Algorithm String content = "test chinese "; // Random key generation byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded(); // structure SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key); // encryption byte[] encrypt = aes.encrypt(content); // Decrypt byte[] decrypt = aes.decrypt(encrypt); // encryption 16 Hexadecimal said String encryptHex = aes.encryptHex(content); System.out.println("AES encryption 16 Hexadecimal said :" + encryptHex); // Decrypt to string String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8); System.out.println("AES Decrypt to string :" + decryptStr); // The second kind DESede encryption String content2 = "test chinese "; byte[] key2 = SecureUtil.generateKey(SymmetricAlgorithm.DESede.getValue()).getEncoded(); SymmetricCrypto des = new SymmetricCrypto(SymmetricAlgorithm.DESede, key2); // encryption byte[] encrypt2 = des.encrypt(content2); // Decrypt byte[] decrypt2 = des.decrypt(encrypt2); // Encrypted to 16 Base string (Hex Express ) String encryptHex2 = des.encryptHex(content2); System.out.println("DESede encryption 16 Hexadecimal said :" + encryptHex2); String decryptStr2 = des.decryptStr(encryptHex2); System.out.println("DESede Decrypt to string :" + decryptStr2); // The third kind of AES encapsulation String content3 = "test chinese "; // Random key generation byte[] key3 = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded(); // structure AES aes3 = SecureUtil.aes(key3); // encryption byte[] encrypt3 = aes3.encrypt(content3); // Decrypt byte[] decrypt3 = aes3.decrypt(encrypt3); // Encrypted to 16 Hexadecimal said String encryptHex3 = aes3.encryptHex(content3); System.out.println("AES Encapsulation encryption 16 Hexadecimal said :" + encryptHex3); // Decrypt to string String decryptStr3 = aes3.decryptStr(encryptHex3, CharsetUtil.CHARSET_UTF_8); System.out.println("AES Encapsulate and decrypt as string :" + decryptStr3); } }
DFA lookup (Hutool-dfa)in the light of DFA Algorithm and some implementation on the Internet ,Hutool It has been sorted out and improved , Finally, it will form the present Hutool-dfa modular
database (Hutool-db)
Hutool-db It's a JDBC Database operation tool class encapsulated on the basis of , By packing , Use ActiveRecord Think about operating the database . stay Hutool-db in , Use Entity( It's essentially a Map) Instead of Bean Make database operation more flexible , At the same time provide Bean and Entity The transformation of provides traditional ORM Compatible support for .
HTTP client (Hutool-http)Hutool-http in the light of JDK Of HttpUrlConnection Make a layer of packaging , To simplify the HTTPS request 、 Upload files 、Cookie Memory and other operations , send Http The request becomes extremely simple
Timing task (Hutool-cron)Hutool The timing task module and Linux Of Crontab It's very similar in use , Through one cron.setting The configuration file , Simple call start() The method can be used simply .
It also provides second matching and year matching Quartz There are only functions , The expressions of timed tasks are also compatible with Crontab(Cron4j) and Quartz The expression of .
Expand (Hutool-extra)because Hutool The principle is not to rely on other configuration files , But most of the time, we need to do some tool classification support for the third-party libraries , therefore Hutoo-extra Package is mainly used to support tool class support of third-party libraries
Bloon filtration (Hutool-bloomFilter)The bloon filter ( English :Bloom Filter) yes 1970 Proposed by bron in . It's actually a very long binary vector and a series of random mapping functions . The bloom filter can be used to retrieve whether an element is in a collection . Its advantage is that the space efficiency and query time are far more than the general algorithm , The disadvantage is that it has certain error recognition rate and deletion difficulty .
The principle of Bloom filter is , When an element is added to a collection , adopt K Hash functions map this element to... In a group of bits K A little bit , Set them as 1. Search time , We just need to see if these points are all 1 Just ( about ) Know if it's in the collection : If any of these points 0, The inspected element must not be in ; If it's all 1, Then the inspected element is likely to be . This is the basic idea of bloon filter .
Reference resources :https://www.cnblogs.com/z941030/p/9218356.html
section (Hutool-aop)AOP The module is mainly for JDK Dynamic proxy in , Abstract dynamic proxy is faceted class Aspect, adopt ProxyUtil The proxy tool class merges the faceted object with the proxied object , Generate a proxy object , Thus, common functions can be performed before and after the execution of each method .
Script (Hutool-script)script The module is mainly for Java Of javax.script encapsulation , Can run Javascript Script .
This module is very simple . The main functions are focused on SCriptUtil In this tool class .
Office The document operation (Hutool-poi)Hutool-poi Is aimed at Apache POI Encapsulation , Therefore, users need to introduce POI library ,Hutool Default not to introduce .
system call (Hutool-system)System property calls -SystemUtil and Oshi encapsulation -OshiUtil
Graphic verification code (Hutool-captcha)Verification code generation and verification function
The Internet Socket(Hutool-socket)When developing web applications , We'll meet again Socket The concept .Socket It's an abstract concept , An application passes through a Socket To establish a remote connection , and Socket Through internal TCP/IP The protocol transmits data to the network .
JDK Provided in Socket function , Include :
BIO
NIO
AIO
Hutool Only aim at NIO and AIO It's a simple package , For simplification Socket Asynchronous development .
For more specific usage, please refer to Official documents
Please like it , Form good habits !
Please leave a message if you have any questions !
边栏推荐
- Does Fortran have a standard library
- Kubernetes 1.24:statefulset introduces maxunavailable copies
- Several reasons and solutions of virtual machine Ping failure
- rk3399_9.0去掉设置的一级菜单network & internet
- 小程序警告:Now you can provide attr `wx:key` for a `wx:for` to improve performance.
- 如何构建以客户为中心的产品蓝图:来自首席技术官的建议
- Wechat applet date comparison, calculation days
- Interview question details
- 2022 the 15th Nanjing International Digital Industry Expo
- This awesome low code generator is now open source!
猜你喜欢

AutoCAD - set text spacing and line spacing

How to solve the problem that SVN cannot open the URL address

KAtex problem - the style of equal sign alignment in CSDN editing

初试c语言之第二次笔记

AUTOCAD——设置文字间距与行距

4. Meet panuon again UI. Title bar of silver form
![[logodetection dataset processing] (4) extract the logo area of each picture](/img/cf/a8d5f840f52a56d498fa36b2343c07.png)
[logodetection dataset processing] (4) extract the logo area of each picture

Problems with database creation triggers

How the WordPress administrator user name was leaked

2022 the 14th Nanjing International artificial intelligence product exhibition
随机推荐
Collision detection unity experiment code
Get to know RPC
Comment construire un plan de produit axé sur le client: conseils du CTO
KAtex problem - the style of equal sign alignment in CSDN editing
CRM对企业以及销售员有哪些帮助?
Even some people say that ArrayList is twice as large. Today, I will take you to tear up the ArrayList source code
OpenTelemetry Metrics发布候选版本
what‘t the meaning of “de facto“
NC | Wang Jun / song Mozhi combined with third-generation sequencing to analyze the structural variation and function of intestinal flora
Ada Logics:CRI-O整体安全审计项目
CG碰撞检测 Collision Testing
[logodetection data set processing] (2) draw the label box of the training set picture
At the early stage of product development, do you choose to develop apps or applets?
Google Earth Engine(GEE)——基于s2影像的实时全球10米土地利用/土地覆盖(LULC)数据集
4、再遇Panuon.UI.Silver之窗体标题栏
洞见科技入选「爱分析· 隐私计算厂商全景报告」,获评金融解决方案代表厂商
How the WordPress administrator user name was leaked
This awesome low code generator is now open source!
Golang uses reflection to directly copy data from one structure to another (through the same fields)
LeetCode_20(括号匹配)


