Try-with-resource eclipse pattern?

Eclipse supports try-with-resource, something like this:

try(Outputstream resource = new FileOutputStream(file)){
// do something...
}

Many years have passed since this feature was added to eclipse, but there is no "try-with-reousource" template. there is only one try-catch.

I tried to create a template, for example try($type{} ${localVar} = new $type{}){ {$cursor{} }, but was useless. (non-car types were also proposed)

Is there any useful try-with-resource pattern?

+4
source share
1 answer

Eclipse does not have a try-with-resource template.

There is an open problem for it: Error 351864 - [1.7] [templates] Add the template "try-with-resource"

+1

Source: https://habr.com/ru/post/1540862/


All Articles