![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
常用工具类
hzz_321
你好 hello world
展开
-
统一异常处理@ExceptionHandler
在开发过程中,我们会遇到很多的异常,比方说:500,如果直接返回给用户,则显得很low,此时我们就需要捕获异常 先举个下例子: 1)简单异常的捕获 public class ErrorController { //一般情况下初学者都会用try-catch来进行简单的异常捕获,如下所示 // 1)一般情况下 public String testError(int a) { i...原创 2018-07-30 11:02:05 · 12212 阅读 · 2 评论 -
常用的UTILS工具类:主键随机数;随机字符/数工具类;redis缓存工具类
1. 生成主键随机数: 时间+随机数 public class KeyUtil { /** * 生成唯一的主键 * 格式: 时间+随机数 * @return */ public static synchronized String getKey() { Random random = new Random(); ...原创 2018-07-17 19:34:28 · 387 阅读 · 0 评论 -
读取excel表格进行数据库数据的插入
读取excel表格的工具类 package com.imooc.utils; import java.io.IOException; import java.io.InputStream; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import ...原创 2018-07-17 19:56:37 · 966 阅读 · 0 评论 -
Java如何在不存在文件夹的目录下创建文件
今天用到的,就随手进入我的囊中。 String outPutPath="F:\\a.txt";File fileNew = new File(outPutPath); File fileParent = fileNew.getParentFile(); if(!fileParent.exists()){ fileParent.mkdirs(); } fileNew.createNewF...原创 2018-07-26 21:24:49 · 2366 阅读 · 0 评论 -
格式化时间样式的字符串
好记性不如烂笔头(不喜勿喷),有好的可以给我,我们一起进步 package com.o2o.util; import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java....原创 2019-01-03 14:40:38 · 238 阅读 · 0 评论