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

张小明 2025/12/26 17:11:49
开发公司让员工顶名买房套取贷款,外贸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进行投诉反馈,一经查实,立即删除!

php网站接口开发梅州建设网站

C中的安全指针(智能指针)主要用于自动内存管理,避免内存泄漏和悬挂指针。主要有以下几种: 1. 标准库智能指针 unique_ptr(独占指针) 特点:独享所有权,不可复制,可移动适用…

张小明 2025/12/26 19:43:37 网站建设

制作网站的基本流程洋桥网站建设

把钱交给理财专家 —— 基金:普通人的财富增值捷径很多人都有这样的困惑:想理财却没时间研究股票、看不懂债券条款、怕踩雷不敢买理财,眼睁睁看着钱躺在活期账户里 “缩水”。其实,解决这个问题的答案很简单 ——基金。它就像 “大…

张小明 2025/12/26 17:43:30 网站建设

上海制作网站开发wordpress国内几大主题

大模型推理框架选型指南:vLLM、TensorRT-LLM、Ollama等主流方案对比 在大语言模型从实验室走向真实业务的今天,部署效率往往比训练更关键。一个70B级别的模型,未经优化时可能需要十几张A100才能勉强服务,而通过合适的推理框架优化…

张小明 2025/12/26 18:31:11 网站建设

网站建设业务越做越累网站备案核验单

终极指南:new-api智能API网关的快速部署与高效应用 【免费下载链接】new-api 基于One API的二次开发版本,仅供学习使用! 项目地址: https://gitcode.com/gh_mirrors/ne/new-api 在AI应用开发的道路上,开发者们常常面临一个…

张小明 2025/12/26 17:40:20 网站建设

制作一个自己的网站36优化大师下载安装

文献综述:基于知识的精益研发(Knowledge-based Lean R&D / Lean Product Development)的研究脉络与关键议题 研究共同问题:为什么“精益”在研发中离不开“知识” 从你筛选的文献摘要线索来看,研究者普遍面对同一矛…

张小明 2025/12/26 17:13:57 网站建设

网站建设套餐联系方式网页交互设计报价

carsim与matlab联防,采用安全距离与ttc触发,通过触发模块控制路径规划,生成换道路径,触发采用stateflow, 在生成的轨迹簇中寻找最优轨迹,模型仅供参考(03)。汽车智能驾驶系统开发中最有意思的部分,莫过于让…

张小明 2025/12/26 15:53:14 网站建设