My Java CheatSheet

  1. InputStream to String https://stackoverflow.com/questions/309424/how-do-i-read-convert-an-inputstream-into-a-string-in-java 这里测试了11种方法,结果显示第8中性能最佳,即完全用java自带的类。
  2. Java 调试SSL,输出证书等:-Djavax.net.debug=all guides/security/jsse/ReadDebug.html
  3. 一个开源小工具库:jcabi.com 包含 jcabi-aspects、http、s3、email、ssh等小组件
  4. maven 跑main方法: mvn exec:java -Dexec.mainClass="com.example.Main" windows:mvn exec:java -D"exec.mainClass"="com.example.Main"
    run-main-class-of-maven-project
  5. SpringBoot 转发请求:https://stackoverflow.com/a/43378975
  6. 两个数的绝对值 Java8 Math引入了 *exact() 来处理溢出问题,溢出时会抛异常 Math.abs(Math.subtractExact(num1, num2)) 来自Baedug
  7. 读取PDF文件 org.apache.pdfbox-pdfbox com.itextpdf-itextpdf 来自Baedug
  8. 统计运行时间的类 Spring中的 StopWatch
  9. 泛型运行时获取T的真实类型 this.entityBeanType = ((Class) ((ParameterizedType) getClass() .getGenericSuperclass()).getActualTypeArguments()[0]); https://stackoverflow.com/questions/3437897/how-do-i-get-a-class-instance-of-generic-type-t?answertab=scoredesc
  10. mutator方法(gettersetter方法) 获取然后反射调用 Introspector.getBeanInfo(Foo.class).getPropertyDescriptors() 额外的,得排除getClass https://stackoverflow.com/questions/2638590/best-way-of-invoking-getter-by-reflection
  11. Spring 的BeanUtils拷贝属性时,怎么跳过空值 https://stackoverflow.com/a/32066155
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值