Hutool是一个Java工具包类库,对文件、流、加密解密、转码、正则、线程、XML等JDK方法进行封装,组成各种Util工具类
文档:
依赖
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.3.9</version> </dependency>
代码示例
package com.mouday; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.file.FileReader; import cn.hutool.core.io.file.FileWriter; import cn.hutool.crypto.digest.DigestUtil; import cn.hutool.http.HttpUtil; public class Demo { public static void main(String[] args) { // 时间获取 System.out.println(DateUtil.now()); //2020-07-22 09:15:53 // 文件读写 FileWriter writer = new FileWriter("name.txt"); writer.write("hello"); FileReader reader = new FileReader("name.txt"); System.out.println(reader.readString()); // hash String md5Hex = DigestUtil.md5Hex("hello"); System.out.println(md5Hex); // 5d41402abc4b2a76b9719d911017c592 // get请求 String result1= HttpUtil.get("https://www.baidu.com"); System.out.println(result1); } }