InputStream
toString
https://stackoverflow.com/questions/309424/how-do-i-read-convert-an-inputstream-into-a-string-in-java 这里测试了11种方法,结果显示第8中性能最佳,即完全用java自带的类。- Java 调试SSL,输出证书等:
-Djavax.net.debug=all
guides/security/jsse/ReadDebug.html - 一个开源小工具库:jcabi.com 包含 jcabi-aspects、http、s3、email、ssh等小组件
- 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 - SpringBoot 转发请求:https://stackoverflow.com/a/43378975
- 两个数的绝对值 Java8 Math引入了
*exact()
来处理溢出问题,溢出时会抛异常Math.abs(Math.subtractExact(num1, num2))
来自Baedug - 读取PDF文件
org.apache.pdfbox-pdfbox
com.itextpdf-itextpdf
来自Baedug - 统计运行时间的类 Spring中的 StopWatch
- 泛型运行时获取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 - mutator方法(
getter
、setter
方法) 获取然后反射调用Introspector.getBeanInfo(Foo.class).getPropertyDescriptors()
额外的,得排除getClass https://stackoverflow.com/questions/2638590/best-way-of-invoking-getter-by-reflection - Spring 的BeanUtils拷贝属性时,怎么跳过空值 https://stackoverflow.com/a/32066155
My Java CheatSheet
于 2021-07-13 23:19:18 首次发布