随笔分类 - java封装工具Util
摘要:1、这里用到的是xxx.xlsx的excel表,如果用.xls的旧版excel表可能会报错,需要自己调整代码 (简单的测试,取出内容根据业务自行处理) public static void main(String[] args) throws Exception { File file = new
阅读全文
摘要:1、连接mysql的工具类: package com.jzproject.common.mysql; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import org.springframework
阅读全文
摘要:1、使用stream api对list集合做总数累加计算: List<Integer> profitList = new ArrayList<Integer>(); //使用java8的新特性stream api 做list元素累加,算总和 int total = profitList.stream
阅读全文
摘要:怎么给一张表插入100万条数据,如果用for循环那low暴了,有得等。 借鉴博客:https://blog.csdn.net/gzt19881123/article/details/122815596 解决办法: 1、开启mybatis的batch模式:application.yml文件配置 myb
阅读全文
摘要:借鉴博客:https://wenku.baidu.com/view/ed9246f1cd2f0066f5335a8102d276a2002960e8.html java代码 package com.example.demo01.test; import org.slf4j.Logger; impor
阅读全文
摘要:借鉴博客:https://blog.csdn.net/feinifi/article/details/120302824 使用集合类Collections.sort()方法可对list数据排序,使用案例如下: public static void main(String[] args) { List
阅读全文
摘要:借鉴博客:采用此大佬的demo源码 https://gitee.com/luckytuan/fast-loader 使用传统的文件上传,在操作中发现,文件超过几十M或上百M上传文件有点慢,要等上几分钟或半小时以上,即使是java端做了流的优化。网上查了之后,大文件适合分片上传,也就是把大文件分割成每
阅读全文
摘要:借鉴博客:https://www.jianshu.com/p/64657c9da39f 添加分页插件依赖:pagehelper <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifact
阅读全文
摘要:例如:要取2019-01 到 2020-06之间的所有月份 /**获取两月之间的所有月份*/ public static List<String> getMonthBetween(String minDate, String maxDate){ ArrayList<String> result =
阅读全文
摘要:借鉴博客:https://www.cnblogs.com/yybinger/p/11907193.html 工具文件,可直接调用,亲测有效: package com.powersi.biz.park.network.util; import java.io.*; import java.util.A
阅读全文
摘要:查询sql如下: select (select to_char(wm_concat(a.description)) from project_report_detail a where project_report_id = t.id) as description2 , t.* from proj
阅读全文
摘要:封装的一个简单的导出excel的方法,很整洁简单 javaweb导出excel方法,后台controller: @Action("exportVpn") public void exportVpn() throws IOException { //list数据,我这里放的是map,有序的linked
阅读全文
摘要:在创建文件时,如果路径中的目录(或文件)不存在,则一并生成,方法如下: /** *@Description 创建文件 *@Author zrt *@Param *@Date 2020/7/13 10:03 */ public static void createFile(String path){
阅读全文
摘要:封装的工具不用自己去判断excel中的每一行每一单元,直接根据名称属性赋值给对象,可直接file文件转成list对象数据 2022年10月9日更新 工具类ExcelUtil.java代码: package com.jzproject.common.util.ExcelUtil; import jav
阅读全文