{"id":36425863,"url":"https://github.com/javasync/rxio","last_synced_at":"2026-01-11T18:00:08.577Z","repository":{"id":57720391,"uuid":"136351714","full_name":"javasync/RxIo","owner":"javasync","description":"Asynchronous non-blocking File Reader and Writer library for Java","archived":false,"fork":false,"pushed_at":"2022-12-20T16:13:24.000Z","size":440,"stargazers_count":30,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-04T11:55:58.951Z","etag":null,"topics":["asynchronous","java","java-nio","non-blocking"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javasync.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-06T15:49:43.000Z","updated_at":"2025-05-25T11:57:15.000Z","dependencies_parsed_at":"2023-01-30T01:05:12.252Z","dependency_job_id":null,"html_url":"https://github.com/javasync/RxIo","commit_stats":null,"previous_names":["javasync/asyncfilerw"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/javasync/RxIo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javasync%2FRxIo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javasync%2FRxIo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javasync%2FRxIo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javasync%2FRxIo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javasync","download_url":"https://codeload.github.com/javasync/RxIo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javasync%2FRxIo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28316874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","java","java-nio","non-blocking"],"created_at":"2026-01-11T18:00:08.310Z","updated_at":"2026-01-11T18:00:08.532Z","avatar_url":"https://github.com/javasync.png","language":"Java","readme":"# RxIo\n\n[![Build Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.javasync%3ARxIo\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=com.github.javasync%3ARxIo)\n[![Coverage Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.javasync%3ARxIo\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=com.github.javasync%3ARxIo)\n[![Maven Central Version](https://img.shields.io/maven-central/v/com.github.javasync/RxIo.svg)](https://search.maven.org/artifact/com.github.javasync/RxIo)\n\nThe [`AsyncFiles`](src/main/java/org/javaync/io/AsyncFiles.java) class allows JVM\napplications to easily read/write files asynchronously with non-blocking IO.\n`AsyncFiles` take advantage of Java [AsynchronousFileChannel](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/channels/AsynchronousFileChannel.html)\nto perform  asynchronous I/O operations.\n\n`AsyncFiles` provides equivalent operations to the standard JDK\n[Files](https://docs.oracle.com/javase/10/docs/api/java/nio/file/Files.html)\nclass but using non-blocking IO and an asynchronous API with different \nasynchronous idioms, namely: \n`CompletableFuture`,\njayield [`AsyncQuery`](https://github.com/tinyield/jayield#internals-overview), \n[reactive-streams](https://www.reactive-streams.org) [`Publisher`](https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/org/reactivestreams/Publisher.html),\nKotlin coroutines and Kotlin [Asynchronous Flow](https://kotlinlang.org/docs/flow.html). \n\nIn section [Usage](#Usage) we present some examples using the\n[`AsyncFiles`](src/main/java/org/javaync/io/AsyncFiles.java)\nclass side by side with the corresponding blocking version of\n[Files](https://docs.oracle.com/javase/10/docs/api/java/nio/file/Files.html).\n\n## Installation\n\nFirst, in order to include it to your project,\nsimply add this dependency:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eMaven\u003c/th\u003e\n\u003cth\u003eGradle\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```xml\n\u003cdependency\u003e \n    \u003cgroupId\u003ecom.github.javasync\u003c/groupId\u003e\n    \u003cartifactId\u003eRxIo\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.5\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```groovy\nimplementation 'com.github.javasync:RxIo:1.2.5'\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctable\u003e\n\n## Usage\n\nKotlin examples:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```kotlin\nsuspend fun copyNio(from: String, to: String) {\n  val data = Path(from).readText() // suspension point\n  Path(to).writeText(data)         // suspension point\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```kotlin\nfun copy(from: String, to: String) {\n    val data = File(from).readText()\n    File(to).writeText(data)\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```kotlin\nPath(\"input.txt\")\n  .lines()   // Flow\u003cString\u003e\n  .onEach(::println)\n  .collect() // block if you want to wait for completion\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```kotlin\nPath(\"input.txt\")\n  .readLines() // List\u003cString\u003e\n  .forEach(::println)\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nJava examples:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```java\nAsyncFiles\n  .readAllBytes(\"input.txt\")\n  .thenCompose(bytes -\u003e AsyncFiles.writeBytes(\"output.txt\", bytes))\n  .join(); // block if you want to wait for completion\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```java\nPath in = Paths.get(\"input.txt\");\nPath out = Paths.get(\"output.txt\");\nbyte[] bytes = Files.readAllBytes(in);\nFiles.write(out, bytes);\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```java\nAsyncFiles\n  .asyncQuery(\"input.txt\")\n  .onNext((line, err) -\u003e out.println(line)) // lack check err\n  .blockingSubscribe(); // block if you want to wait for completion\n```\n    \n\u003c/td\u003e\n\u003ctd\u003e\n\n```java\nPath path = Paths.get(\"input.txt\");\nFiles\n  .lines(path)\n  .forEach(out::println)\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```java\nList\u003cString\u003e data = asList(\"super\", \"brave\", \"isel\", \"gain\");\nAsyncFiles\n  .write(\"output.txt\", data) // writing lines to output.txt\n  .join(); // block if you want to wait for completion\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```java\nList\u003cString\u003e data = asList(\"super\", \"brave\", \"isel\", \"gain\");\nPath path = Paths.get(\"output.txt\")\nFiles.write(path, data);\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nThe [`AsyncFiles::lines()`](src/main/java/org/javaync/io/AsyncFiles.java#L84)\nreturns a reactive [`Publisher`](https://www.reactive-streams.org/reactive-streams-1.0.0-javadoc/org/reactivestreams/Publisher.html)\nwhich is compatible with Reactor or RxJava streams. \nThus we can use the utility methods of Reactor [`Flux`](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html)\nto easily operate on the result of `AsyncFiles::lines()`.\nIn the following example we show how to print all words of a gutenberg.org file content without repetitions:\n\n```java\nFlux\n    .from(AsyncFiles.lines(file))\n    .filter(line -\u003e !line.isEmpty())                   // Skip empty lines\n    .skip(14)                                          // Skip gutenberg header\n    .takeWhile(line -\u003e !line.contains(\"*** END OF \"))  // Skip gutenberg footnote\n    .flatMap(line -\u003e Flux.fromArray(line.split(\"\\\\W+\")))\n    .distinct()\n    .doOnNext(out::println)\n    .doOnError(Throwable::printStackTrace)\n    .blockLast(); // block if you want to wait for completion\n```\n\nAlternatively, the [`AsyncFiles::asyncQuery()`](src/main/java/org/javaync/io/AsyncFiles.java#L60)\nreturns an `AsyncQuery` that allows asynchronous subscription and chaining intermediate operations\nsuch as `filter`, `map` and others.\nWe can rewrite the previous sample as:\n```java\nAsyncFiles\n    .asyncQuery(file)\n    .filter(line -\u003e !line.isEmpty())                   // Skip empty lines\n    .skip(14)                                          // Skip gutenberg header\n    .takeWhile(line -\u003e !line.contains(\"*** END OF \"))  // Skip gutenberg footnote\n    .flatMapMerge(line -\u003e AsyncQuery.of(line.split(\"\\\\W+\")))\n    .distinct()\n    .subscribe((word, err) -\u003e {\n        if(err != null) err.printStackTrace();\n        else out.println(word);\n    })\n    .join(); // block if you want to wait for completion\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavasync%2Frxio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavasync%2Frxio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavasync%2Frxio/lists"}