You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/05/20 07:12:00 UTC

[jira] [Updated] (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 ]

Paul King updated GROOVY-8006:
------------------------------
    Summary: [PARROT] Allow dropping 'def' or type in try with resources  (was: [parrot] Allow dropping 'def' or type in try with resources)

> [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
>            Priority: Major
>
> 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
(v7.6.3#76005)