最全的 lombok 注解详情(随着版本不定时更新)
一、注解介绍
作用于变量,自动关闭资源,仅针对实现了 java.io.Closeable 接口的对象有效
二、属性介绍
- value:指定的方法(这个方法需要在注解对象中存在)关闭资源,默认使用 close 方法
如果指定的方法带异常,则需要捕获或者抛出该异常(可以比该异常大)
三、实战演练
public class JingTian {
public static void main(String[] args) {
@Cleanup Scanner scanner = new Scanner(System.in);
try {
@Cleanup Reader<