class MyResource implements Closeable{

    @Override

    public void close() throw IOException{

    }

}

 

try( myResource = new MyResource() ){    // no need to write finally block to release resource, java will automatially close this resource.

}catch(Exception e){

}

相关文章:

  • 2022-01-23
  • 2022-12-23
  • 2022-01-03
  • 2021-10-18
  • 2021-05-21
  • 2022-12-23
  • 2021-12-14
  • 2021-10-30
猜你喜欢
  • 2022-02-11
  • 2021-12-19
  • 2022-12-23
  • 2021-12-04
  • 2021-08-21
  • 2022-12-23
  • 2021-04-16
相关资源
相似解决方案