Eclipse 支持 try-with-resource,有点像这样:
try(Outputstream resource = new FileOutputStream(file)){
// do something...
}
这个功能添加到 Eclipse 已经有好几年了,但是没有模板“try-with-reousource”。只有一个是“try-catch”。
我试图制作模板,例如try($type{} ${localVar} = new $type{}){ {$cursor{} }
,但没用。(还建议使用非 AutoClosable 类型)
是否有任何有用的 try-with-resource 模板?