You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel.Sun (JIRA)" <ji...@apache.org> on 2016/11/26 16:13:58 UTC

[jira] [Closed] (GROOVY-8006) [parrot] Allow dropping 'def' or type in try with resources

     [ https://issues.apache.org/jira/browse/GROOVY-8006?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel.Sun closed GROOVY-8006.
------------------------------
    Resolution: Fixed

> [parrot] Allow dropping 'def' or type in try with resources
> -----------------------------------------------------------
>
>                 Key: GROOVY-8006
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8006
>             Project: Groovy
>          Issue Type: Improvement
>         Environment: Parrot parser
>            Reporter: Guillaume Laforge
>            Assignee: Daniel.Sun
>
> With try with resources, it would be nice to be able the type or def, just like in the classical for loop:
> {code}
> import java.util.zip.GZIPOutputStream


> def input = new File('./NOTICE')
> 
def output = new File('/tmp/zipped.zip')


> try (
> 
   fin = new FileInputStream(input);

>    out = new GZIPOutputStream(new FileOutputStream(output))

> ) {

>     byte[] buffer = new byte[4096]

>     int nread = 0

>     while ((nread = fin.read(buffer)) != -1) {
> 
        out.write(buffer, 0, nread)

>     }

> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)