Re: Suggestion: Should ImagePlus implement
Posted by
Wayne Rasband-2 on
Dec 29, 2020; 2:55pm
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024326.html
> On Dec 27, 2020, at 6:55 AM, Michael Ellis <
[hidden email]> wrote:
>
> Now that ImageJ is Java8 savvy would it be a good idea to make ImagePlus implement the AutoCloseable interface?
Having ImagePlus implement the AutoCloseable interface would require adding “throws Exception” to the close() method, which would cause plugins that call ImagePlus.close() to fail.
-wayne
> This would allow try with resources to be used e.g.
>
>
> try (ImagePlus imp = IJ.openImage(itemPath.toString())) {
> .
> .
> .
> << do lots of stuff with imp that may or may not throw exceptions>>
> .
> } // Autoclose imp
>
> Same applies to any other ImageJ resources that have some close functionality.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html