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

Paul King resolved GROOVY-11902.
--------------------------------
    Resolution: Fixed

Proposed PR merged.

> minor groovy-nio improvements
> -----------------------------
>
>                 Key: GROOVY-11902
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11902
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> ⏺ Asynchronous file I/O extension methods for java.nio.file.Path              
>                                                                               
>                                     
>   Adds six new extension methods to Path via groovy-nio that use 
> AsynchronousFileChannel for non-blocking file I/O, returning 
> CompletableFuture results:
>   Reading:                                                                    
>                                                                               
>                                     
>   - path.getTextAsync() → CompletableFuture<String> (default charset)
>   - path.getTextAsync(charset) → CompletableFuture<String>                    
>                                                                               
>                                     
>   - path.getBytesAsync() → CompletableFuture<byte[]>        
>   Writing:                                                                    
>                                                                               
>                                     
>   - path.writeAsync(text) → CompletableFuture<Void> (default charset)
>   - path.writeAsync(text, charset) → CompletableFuture<Void>                  
>                                                                               
>                                     
>   - path.writeBytesAsync(bytes) → CompletableFuture<Void>   
>   Groovy property syntax works naturally: path.textAsync, path.bytesAsync.
> Usage: 
> {code:groovy}                                                   
> // blocking                                                                   
>                                                                               
>                                   
> def text = path.textAsync.get()                           
> // composition                                                                
>                                                                               
>                                   
> path.textAsync.thenApply { it.toUpperCase() }
> // with async/await (potential future Groovy 6 feature)
> def text = await path.textAsync
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to