开发公司让员工顶名买房套取贷款外贸seo外贸推广外贸网站建设外贸网站建设

张小明 2026/1/19 22:34:47
开发公司让员工顶名买房套取贷款,外贸seo外贸推广外贸网站建设外贸网站建设,做淘宝链接的网站,做网站得每年续费吗Hutool 是一个 Java 工具包#xff0c;它为开发者提供了一系列实用的工具类和方法#xff0c;帮助简化开发工作。本文将详细介绍 Hutool 的主要功能和使用方法#xff0c;帮助开发者更好地利用这个强大的工具包。 1. Hutool 简介 Hutool 是由 dromara 团队开发的一款 Java 工…Hutool 是一个 Java 工具包它为开发者提供了一系列实用的工具类和方法帮助简化开发工作。本文将详细介绍 Hutool 的主要功能和使用方法帮助开发者更好地利用这个强大的工具包。1. Hutool 简介Hutool 是由dromara团队开发的一款 Java 工具包旨在通过提供丰富的工具类减少开发者的重复劳动提升开发效率。Hutool 的设计灵感来源于 Guava、Commons Lang 等工具库但其功能更加全面使用更加简便。Hutool 的特点包括轻量级Hutool 仅依赖 JDK自身没有第三方库依赖。功能全面涵盖字符串处理、日期处理、集合处理、IO 操作、网络操作等常见功能。易用性强简洁的 API 设计使得使用起来非常方便。开源Hutool 是一个开源项目代码托管在 GitHub 上开发者可以自由使用和扩展。2. Hutool 的安装与配置在使用 Hutool 之前需要将其引入项目中。以下是 Maven 和 Gradle 的引入方法MavendependencygroupIdcn.hutool/groupIdartifactIdhutool-all/artifactIdversion5.8.11/version/dependencyGradleimplementationcn.hutool:hutool-all:5.8.113. 常用工具类介绍3.0 JavaBean的工具类BeanUtilJavaBean的工具类可用于Map与JavaBean对象的互相转换以及对象属性的拷贝。3.0.1 Bean属性注入使用Map填充bean首先定义两个bean// Lombok注解DatapublicclassPerson{privateStringname;privateintage;}// Lombok注解DatapublicclassSubPersonextendsPerson{publicstaticfinalStringSUBNAMETEST;privateUUIDid;privateStringsubName;privateBooleanisSlow;}然后注入这个beanPersonpersonBeanUtil.fillBean(newPerson(),newValueProviderString(){OverridepublicObjectvalue(Stringkey,Class?valueType){switch(key){casename:return张三;caseage:return18;}returnnull;}OverridepublicbooleancontainsKey(Stringkey){//总是存在keyreturntrue;}},CopyOptions.create());Assert.assertEquals(person.getName(),张三);Assert.assertEquals(person.getAge(),18);基于BeanUtil.fillBean方法Hutool还提供了Map对象键值对注入Bean其方法有BeanUtil.fillBeanWithMap使用Map填充beanHashMapString,ObjectmapCollUtil.newHashMap();map.put(name,Joe);map.put(age,12);map.put(openId,DFDFSDFWERWER);SubPersonpersonBeanUtil.fillBeanWithMap(map,newSubPerson(),false);BeanUtil.fillBeanWithMapIgnoreCase使用Map填充bean忽略大小写HashMapString,ObjectmapCollUtil.newHashMap();map.put(Name,Joe);map.put(aGe,12);map.put(openId,DFDFSDFWERWER);SubPersonpersonBeanUtil.fillBeanWithMapIgnoreCase(map,newSubPerson(),false);3.0.2 map转bean同时Hutool还提供了BeanUtil.toBean方法用于map转bean与fillBean不同的是此处并不是传Bean对象而是Bean类Hutool会自动调用默认构造方法创建对象。当然前提是Bean类有默认构造方法空构造这些方法有1.BeanUtil.toBeanHashMapString,ObjectmapCollUtil.newHashMap();map.put(a_name,Joe);map.put(b_age,12);// 设置别名用于对应bean的字段名HashMapString,StringmappingCollUtil.newHashMap();mapping.put(a_name,name);mapping.put(b_age,age);PersonpersonBeanUtil.toBean(map,Person.class,CopyOptions.create().setFieldMapping(mapping));2.BeanUtil.toBeanIgnoreCaseHashMapString,ObjectmapCollUtil.newHashMap();map.put(Name,Joe);map.put(aGe,12);PersonpersonBeanUtil.toBeanIgnoreCase(map,Person.class,false);3.0.3 Bean转为MapBeanUtil.beanToMap方法则是将一个Bean对象转为Map对象。SubPersonpersonnewSubPerson();person.setAge(14);person.setOpenid(11213232);person.setName(测试A11);person.setSubName(sub名字);MapString,ObjectmapBeanUtil.beanToMap(person);3.0.4 Bean转BeanBean之间的转换主要是相同属性的复制因此方法名为copyProperties此方法支持Bean和Map之间的字段复制。BeanUtil.copyProperties方法同样提供一个CopyOptions参数用于自定义属性复制。Bean转Bean// 创建源对象UsersourcenewUser();source.setUserId(5);source.setUserName(Alice);source.setAge(30);// 创建目标对象UsertargetnewUser();// 忽略年龄属性的复制BeanUtil.copyProperties(source,target,age);System.out.println(target target);// 或者使用CopyOptions忽略多个属性CopyOptionsoptionsCopyOptions.create().setIgnoreProperties(age,otherProperty);//source---target 源对象 目标对象 忽略的属性BeanUtil.copyProperties(source,target,options);System.out.println(target target);Bean转mapSubPersonp1newSubPerson();p1.setSlow(true);p1.setName(测试);p1.setSubName(sub测试);MapString,ObjectmapMapUtil.newHashMap();BeanUtil.copyProperties(p1,map);5.6.6加入copyToList方法遍历集合中每个Bean复制其属性到另一个类型的对象中最后返回一个新的List。ListStudentstudentListnewArrayList();StudentstudentnewStudent();student.setName(张三);student.setAge(123);student.setNo(3158L);studentList.add(student);Studentstudent2newStudent();student.setName(李四);student.setAge(125);student.setNo(8848L);studentList.add(student2);// 复制到 Person 类源对象集合 目标对象的类型ListPersonpeopleBeanUtil.copyToList(studentList,Person.class);3.1 字符串工具类Hutool 提供了StrUtil类用于处理字符串的常见操作。以下是一些常用的方法3.1.1 判断字符串是否为空StringstrHello Hutool;booleanisEmptyStrUtil.isEmpty(str);// falsebooleanisBlankStrUtil.isBlank(str);// false3.1.2 字符串拼接StringresultStrUtil.join(, ,a,b,c);// a, b, c3.1.3 字符串分割ListStringlistStrUtil.split(a, b, c,,);// [a, b, c]3.1.4 字符串替换StringresultStrUtil.replace(Hello World,World,Hutool);// Hello Hutool3.2 集合工具类Hutool 提供了CollUtil工具类用于处理集合的常见操作。以下是一些常用的方法3.2.1 判断集合是否为空ListStringlistArrays.asList(a,b,c);booleanisEmptyCollUtil.isEmpty(list);// falsebooleanisNotEmptyCollUtil.isNotEmpty(list);// true3.2.2 集合拼接ListStringlist1Arrays.asList(a,b);ListStringlist2Arrays.asList(c,d);ListStringresultCollUtil.addAll(list1,list2);// [a, b, c, d]3.2.3 集合去重ListStringlistArrays.asList(a,b,a);ListStringresultCollUtil.distinct(list);// [a, b]3.3 日期时间工具类Hutool 提供了DateUtil工具类用于处理日期和时间的常见操作。以下是一些常用的方法3.3.1 获取当前时间DatenowDateUtil.date();// 当前时间StringnowStrDateUtil.now();// 当前时间字符串3.3.2 格式化日期DatedateDateUtil.parse(2023-07-29);StringformattedDateDateUtil.format(date,yyyy/MM/dd);// 2023/07/293.3.3 日期加减DatedateDateUtil.date();DatenewDateDateUtil.offsetDay(date,5);// 当前日期加5天3.4 文件工具类Hutool 提供了FileUtil工具类用于处理文件操作。以下是一些常用的方法3.4.1 读取文件内容StringcontentFileUtil.readUtf8String(path/to/file.txt);3.4.2 写入文件内容FileUtil.writeUtf8String(Hello Hutool,path/to/file.txt);3.4.3 文件复制FileUtil.copy(path/to/source.txt,path/to/dest.txt,true);3.5 HTTP 工具类Hutool 提供了HttpUtil工具类用于处理 HTTP 请求。以下是一些常用的方法3.5.1 发送 GET 请求StringresultHttpUtil.get(http://example.com);3.5.2 发送 POST 请求MapString,ObjectparamMapnewHashMap();paramMap.put(key1,value1);paramMap.put(key2,value2);StringresultHttpUtil.post(http://example.com,paramMap);4. 其他实用功能4.1 加密解密Hutool 提供了SecureUtil工具类用于加密解密操作。以下是一些常用的方法4.1.1 MD5 加密Stringmd5SecureUtil.md5(password);4.1.2 AES 加密解密AESaesSecureUtil.aes();Stringencryptedaes.encryptHex(Hello Hutool);Stringdecryptedaes.decryptStr(encrypted);4.2 JSON 处理Hutool 提供了JSONUtil工具类用于 JSON 数据的处理。以下是一些常用的方法4.2.1 对象转 JSONUserusernewUser(John,30);StringjsonJSONUtil.toJsonStr(user);4.2.2 JSON 转对象Stringjson{\name\:\John\,\age\:30};UseruserJSONUtil.toBean(json,User.class);4.3 Excel 处理Hutool 提供了ExcelUtil工具类用于 Excel 文件的处理。以下是一些常用的方法4.3.1 读取 Excel 文件ExcelReaderreaderExcelUtil.getReader(path/to/file.xlsx);ListUserusersreader.readAll(User.class);4.3.2 写入 Excel 文件ListUserusersArrays.asList(newUser(John,30),newUser(Jane,25));ExcelWriterwriterExcelUtil.getWriter(path/to/file.xlsx);writer.write(users);writer.close();4.4 QR 码生成Hutool 提供了QrCodeUtil工具类用于生成 QR 码。以下是一些常用的方法4.4.1 生成 QR 码图片QrCodeUtil.generate(Hello Hutool,300,300,FileUtil.file(path/to/qrcode.png));4.4.2 生成带 logo 的 QR 码图片QrCodeUtil.generate(Hello Hutool,300,300,FileUtil.file(path/to/qrcode.png),FileUtil.file(path/to/logo.png));5. 综合案例为了更好地展示 Hutool 的强大功能下面通过一个综合案例来说明如何在实际开发中使用 Hutool。案例用户注册系统假设我们要开发一个简单的用户注册系统功能包括用户注册、登录、密码加密存储、用户信息导出等。我们将利用 Hutool 来实现这些功能。5.1 用户注册首先我们定义一个 User 类来表示用户信息publicclassUser{privateStringusername;privateStringpassword;privateStringemail;// Getter 和 Setter 方法}然后我们实现用户注册功能publicclassUserService{privateListUserusersnewArrayList();publicvoidregister(Stringusername,Stringpassword,Stringemail){StringencryptedPasswordSecureUtil.md5(password);UserusernewUser();user.setUsername(username);user.setPassword(encryptedPassword);user.setEmail(email);users.add(user);}}5.2 用户登录接下来我们实现用户登录功能publicbooleanlogin(Stringusername,Stringpassword){StringencryptedPasswordSecureUtil.md5(password);for(Useruser:users){if(user.getUsername().equals(username)user.getPassword().equals(encryptedPassword)){returntrue;}}returnfalse;}5.3 用户信息导出最后我们实现用户信息导出到 Excel 文件publicvoidexportUserInfo(StringfilePath){ExcelWriterwriterExcelUtil.getWriter(filePath);writer.write(users);writer.close();}通过以上代码我们可以看到 Hutool 提供的工具类极大地简化了加密、集合操作和文件操作等任务。6. 总结Hutool 是一个功能强大且易用的 Java 工具包它提供了丰富的工具类涵盖了日常开发中的各种常见操作。通过本文的介绍希望读者能够对 Hutool 有一个全面的了解并能在实际开发中熟练使用它从而提升开发效率。如果您还未使用过 Hutool不妨尝试一下相信它会成为您开发中的得力助手。
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

常见的建站工具直接进入网站的代码

Excalidraw:如何用一张“手绘草图”重塑技术沟通 你有没有经历过这样的场景?在一场远程架构评审会上,后端工程师对着屏幕念着文档:“用户请求先经过网关,然后路由到订单服务……”而前端同事却皱着眉头问:“…

张小明 2026/1/19 12:33:07 网站建设

cms建站系统免费郑州建设劳务管理中心网站

如何快速搭建个人天气数据服务:Open-Meteo开源API完整指南 【免费下载链接】open-meteo Free Weather Forecast API for non-commercial use 项目地址: https://gitcode.com/gh_mirrors/op/open-meteo 想要获取专业的天气预报信息却不想花费高昂费用&#xf…

张小明 2026/1/19 4:24:15 网站建设

有做微信婚介网站的吗装修设计公司哪家

GAWK实用功能全解析:调试、排序、通信与网络编程 1. GAWK调试环境操作 在GAWK调试环境中,我们可以使用 next 命令单步执行指令。例如: gawk> next Addition of 30 + 10 : 40 calc() at `calc.awk:19 19 find_sub(40,10)1.1 查看环境信息 使用 info 命令(或缩写…

张小明 2026/1/19 12:26:07 网站建设

android网站开发实例网站建设优化是什么鬼

一、场景背景 腾讯 ADP(智能应用开发平台)提供的大模型问答接口基于 HTTP SSE(Server-Sent Events)协议返回流式数据,数据分批次推送且通过is_final字段标识最终完整结果。本文聚焦该场景,提供通用的 SSE 流式响应处理方案,精准提取接口返回的最终结果,保证 UTF-8 编码…

张小明 2026/1/19 12:28:29 网站建设

提供商城网站做网站公司需要帮客户承担广告法吗

嵌入式Linux系统开发:NOR闪存修复、文件系统创建与硬件定义方法 1. NOR闪存重编程 当NOR闪存出现问题时,可以通过开发板的JTAG端口对其进行重编程。Mini2440套件中有一个名为JTAG “wiggler”的设备,它可以插入PC的并行端口,并连接到开发板上的10针扁平电缆JTAG端口。需要…

张小明 2026/1/19 16:18:40 网站建设

查询网站内页关键词排名网页前端开发和后端开发

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 创建一个交互式博图学习向导,引导用户完成从软件安装到第一个PLC项目的全过程。包含:1)分步骤安装指导;2)界面导览;3)创建一个简单的电机启停控制…

张小明 2026/1/19 8:50:33 网站建设