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 2026/04/04 11:24:00 UTC
[jira] [Updated] (GROOVY-11902) minor groovy-nio improvements
[ https://issues.apache.org/jira/browse/GROOVY-11902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-11902:
-------------------------------
Description:
⏺ 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}
was:
There are some small async-friendly methods we could add to groovy-nio:
getTextAsync, getTextAsync(charset), getBytesAsync, writeAsync, writeAsync(charset), writeBytesAsync
> 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)