@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();
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-11-16
  • 2021-08-07
  • 2021-08-09
  • 2021-09-07
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案