All Projects → javasync → RxIo

javasync / RxIo

Licence: MIT license
Asynchronous non-blocking File Reader and Writer library for Java

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to RxIo

Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (+450%)
Mutual labels:  asynchronous, non-blocking
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+1505%)
Mutual labels:  asynchronous, non-blocking
Lightning
A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework
Stars: ✭ 312 (+1460%)
Mutual labels:  asynchronous, non-blocking
Cmd
Non-blocking external commands in Go with and streaming output and concurrent-safe access
Stars: ✭ 477 (+2285%)
Mutual labels:  asynchronous, non-blocking
Parallel Ssh
Asynchronous parallel SSH client library.
Stars: ✭ 864 (+4220%)
Mutual labels:  asynchronous, non-blocking
Zsh Autocomplete
🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
Stars: ✭ 641 (+3105%)
Mutual labels:  asynchronous, non-blocking
Mio
Metal IO library for Rust
Stars: ✭ 4,613 (+22965%)
Mutual labels:  asynchronous, non-blocking
Base64 Async
Non-blocking chunked Base64 encoding
Stars: ✭ 98 (+390%)
Mutual labels:  asynchronous, non-blocking
Future
High-performance Future implementation for the JVM
Stars: ✭ 223 (+1015%)
Mutual labels:  asynchronous, non-blocking
Anjani
🤖 Telegram group management bot with spam protection
Stars: ✭ 45 (+125%)
Mutual labels:  asynchronous
aioconnectors
Simple secure asynchronous message queue
Stars: ✭ 17 (-15%)
Mutual labels:  asynchronous
RAII.scala
Resource Acquisition Is Initialization
Stars: ✭ 31 (+55%)
Mutual labels:  asynchronous
neuron.nvim
Make neovim the best note taking application
Stars: ✭ 340 (+1600%)
Mutual labels:  asynchronous
remoting
Jetlang Remoting - asynchronous distributed messaging
Stars: ✭ 27 (+35%)
Mutual labels:  asynchronous
py3tftp
An asynchronous TFTP server in pure Python 3.5
Stars: ✭ 39 (+95%)
Mutual labels:  asynchronous
asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+670%)
Mutual labels:  asynchronous
cephgeorep
An efficient unidirectional remote backup daemon for CephFS.
Stars: ✭ 27 (+35%)
Mutual labels:  asynchronous
fs
File system utility library for Clojure
Stars: ✭ 94 (+370%)
Mutual labels:  java-nio
AppListManager
📱 AppListManager (Android Library) makes managing application and activity lists easy.
Stars: ✭ 59 (+195%)
Mutual labels:  asynchronous
Session
PHP Session Manager (non-blocking, flash, segment, session encryption)
Stars: ✭ 23 (+15%)
Mutual labels:  non-blocking

RxIo

Build Status Coverage Status Maven Central Version

The AsyncFiles class allows Java applications to easily read/write files asynchronously and without blocking. This is an equivalent to the standard JDK Files class but using non-blocking IO. In section Usage we present some examples using the AsyncFiles class side by side with the corresponding blocking version of Files.

Installation

First, in order to include it to your project, simply add this dependency:

Maven Gradle
<dependency> 
    <groupId>com.github.javasync</groupId>
    <artifactId>RxIo</artifactId>
    <version>1.2.1</version>
</dependency>
implementation 'com.github.javasync:RxIo:1.2.1'

Usage

String path = "input.txt";
AsyncFiles
  .asyncQuery(path) // printing all lines from input.txt
  .subscribe((line, err) -> out.println(line)) // lack check err
  .join(); // block if you want to wait for completion
Path path = Paths.get("input.txt");
Files
  .lines(path) // printing all lines from input.txt
  .forEach(out::println)
Path path = Paths.get("output.txt")
List<String> data = asList("super", "brave", "isel", "gain");
AsyncFiles
  .write(path, data) // writing lines to output.txt
  .join(); // block if you want to wait for completion
/**
 *  Writing lines to output.txt
 */
Path path = Paths.get("output.txt")
List<String> data = asList("super", "brave", "isel", "gain");
Files.write(path, data);
Path in = Paths.get("input.txt");
Path out = Paths.get("output.txt");
AsyncFiles
  .readAllBytes(in)
  .thenCompose(bytes -> AsyncFiles.writeBytes(out, bytes))
  .join(); // block if you want to wait for completion
/**
 * Copying from one file to another.
 */
Path in = Paths.get("input.txt");
Path out = Paths.get("output.txt");
byte[] bytes = Files.readAllBytes(in);
Files.write(out, bytes);

The AsyncFiles::asyncQuery() returns an AsyncQuery that allows asynchronous subscription and chaining intermediate operations such as filter, map and others. In the following example we show how to print all words of a gutenberg.org file content without repetitions:

AsyncFiles
    .asyncQuery(file)
    .filter(line -> !line.isEmpty())                   // Skip empty lines
    .skip(14)                                          // Skip gutenberg header
    .takeWhile(line -> !line.contains("*** END OF "))  // Skip gutenberg footnote
    .flatMapMerge(line -> AsyncQuery.of(line.split("\\W+")))
    .distinct()
    .subscribe((word, err) -> {
        if(err != null) err.printStackTrace();
        else out.println(word);
    })
    .join(); // block if you want to wait for completion

Alternatively, the AsyncFiles::lines() returns a reactive Publisher which is compatible with Reactor or RxJava streams. Thus we can use their utility methods to easily operate on the result of AsyncFiles::lines(). For example, with the utility methods of Reactor Flux we can rewrite the previous sample as:

Flux
    .from(AsyncFiles.lines(file))
    .filter(line -> !line.isEmpty())                   // Skip empty lines
    .skip(14)                                          // Skip gutenberg header
    .takeWhile(line -> !line.contains("*** END OF "))  // Skip gutenberg footnote
    .flatMap(line -> Flux.fromArray(line.split("\\W+")))
    .distinct()
    .doOnNext(out::println)
    .doOnError(Throwable::printStackTrace)
    .blockLast(); // block if you want to wait for completion
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].