I am trying to implement [AutoClosable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) InputStream in groovy but it is unable to recognize syntax for below snippet, which I took from my old project's Java class

```
try (InputStream istream = new FileInputStream(new File(relativePath))) {
    return IOUtils.toString(istream));
} catch (IOException e) {
    e.printStackTrace();
}

```

So instead I used `new File(relativePath).getText()` which works.

```
def static getTemplateAsString(def relativePath) {
    /*try (InputStream istream = new FileInputStream(new File(relativePath))) {
        return IOUtils.toString(istream));
    } catch (IOException e) {
        e.printStackTrace();
    }*/
    try {
        return new File(relativePath).getText()
    } catch (FileNotFoundException fnfe) {
        fnfe.printStackTrace()
    } catch (IOException ioe) {
        ioe.printStackTrace()
    } catch (Exception e) {
        e.printStackTrace()
    }
    return null
}

```

I have 2 questions

1. Does `new File(relativePath).getText()` auto release file resource similar to [AutoClosable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html), where can I find it's doc?
2. Why isn't `try (InputStream istream = new FileInputStream(new File(relativePath)))` syntax working in groovy?

Groovy: 2.4.7,
JVM: 1.8.0\_111