A small but complete Java utility class library – Hutool

A small but complete Java utility class library – Hutool

2022-09-01 0 1,047
Resource Number 36627 Last Updated 2025-02-24
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This edition recommends a Java utility class library called Hutool.

Hutool is a small and complete Java utility class library, through static method encapsulation, reduce the learning cost of related apis, improve work efficiency, and make Java have a functional language like elegance. Hutool is a friendly alternative to the “util” package in a project. It saves developers time to package common classes and common tool methods in the project, keeps development focused on the business, and minimizes bugs caused by imperfect packaging.

164b57aa86e04b96aa6d5926e7b5ca67noop.image_

Hutool includes:

659e9d3b272b47e2b14049c21422c540noop.image_

rely on

  • Maven
<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.13</version></dependency>
  • Gradle
implementation 'cn.hutool:hutool-all:5.7.13'

Example:

Type conversion utility class -Convert

The Convert class encapsulates conversions for common Java types to simplify type conversions.

/***Convert to string*/int a = 1;//aStr"1"String aStr = Convert.toStr(a);long[] b = {1,2,3,4,5};//bStr:"[1, 2, 3, 4, 5]"String bStr = Convert.toStr(b);
/*** Convert to set*/Object[] a = {"a", "you", "good", "", 1};List<?> list = Convert.convert(List.class, a);//form 4.1.11You can start with thatList<?> list = Convert.toList(a);
  • Date and Time tool -DateUtil

    DateUtil encapsulates mainly the conversion between date and string, and provides the location of the date (one month ago, etc.)

/*** Date、long、CalendarConversion between */// Current time Date date = DateUtil.date();//current timeDate date2 = DateUtil.date(Calendar.getInstance());//current timeDate date3 = DateUtil.date(System.currentTimeMillis());//Current date string, format:yyyy-MM-dd HH:mm:ssString now = DateUtil.now();//Current date string, format:yyyy-MM-ddString today= DateUtil.today();
  • File utility class -FileUtil

    The FileUtil class contains the following operation tools:

    File operations: include creating, deleting, copying, moving, and changing names of file directories
    File judgment: Determine whether the file or directory is non-empty, whether it is a directory, whether it is a file, and so on.
    Absolute path: Convert files in the ClassPath to absolute path files.
    File name: The name of the main file and the extension
    Read operations: including getReader and readXXX operations in IoUtil
    Write operations: include getWriter and writeXXX operations
    Unique ID tool -IdUtil

/*** Generate UUID*/// The generated UUID is a string with -, similar to: a5c8a5e8-df2b-4706-bea4-08d0939410e3String uuid = IdUtil.randomUUID(); // Generates a string without -, similar to:b17f24ff026d40949c85a24f4f375d42String simpleUUID = IdUtil.simpleUUID();
/*** Generate Snowflake*/// Parameter 1 is the terminal ID// Parameter 2 is the data centerIDSnowflake snowflake = IdUtil.getSnowflake(1, 1);long id = snowflake.nextId();
  • DesensitizedUtil Information desensiTIZEDUtil
// Id number 5 * * * * * * * * * * * * * * * 1 xdesensitizedutil. IdCardNum (" x 51343620000320711 ", 1, 2); // Mobile phone number180****1999DesensitizedUtil.mobilePhone("18049531999");

Read the Hutool reference for more information on your ownHutool参考文档

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code A small but complete Java utility class library – Hutool https://ictcoder.com/kyym/a-small-but-complete-java-utility-class-library-hutool.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service