Lombok(1.14.8) - @SneakyThrows

@SneakyThrows

@SneakyThrows,声明异常。

package com.huey.lombok;

import java.io.UnsupportedEncodingException;

import lombok.SneakyThrows;

public class SneakyThrowsExample implements Runnable {
    
    @SneakyThrows(UnsupportedEncodingException.class)
    public String utf8ToString(byte[] bytes) {
        return new String(bytes, "UTF-8");
    }

    @SneakyThrows
    public void run() {
        throw new Throwable();
    }
}

 

posted on 2015-08-02 00:16  huey2672  阅读(1329)  评论(0编辑  收藏  举报