io.vertx.rxjava.core.file.FileSystem Java Examples

The following examples show how to use io.vertx.rxjava.core.file.FileSystem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeployApplicationService.java    From vertx-deploy-tools with Apache License 2.0 6 votes vote down vote up
public Observable<Boolean> cleanup() {
    List<String> runningApplications = new ProcessUtils(config).listModules();
    FileSystem fs = new io.vertx.rxjava.core.Vertx(vertx).fileSystem();


    return fs.rxReadDir(config.getRunDir())
            .toObservable()
            .flatMapIterable(x -> x)
            .flatMap(s -> just(Pattern.compile("/").splitAsStream(s).reduce((a, b) -> b).orElse("")))
            .filter(s -> !s.isEmpty() && !runningApplications.contains(s))
            .flatMap(file -> fs.rxDelete(config.getRunDir() + file).toObservable())
            .toList()
            .flatMap(x -> just(Boolean.TRUE).doOnError(t -> LOG.error("error")))
            .onErrorReturn(x -> {
                LOG.error("Error during cleanup of run files {}", x.getMessage());
                return Boolean.FALSE;
            });
}
 
Example #2
Source File: RxifiedExamples.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
public void toObservable(Vertx vertx) {
  FileSystem fs = vertx.fileSystem();
  fs.open("/data.txt", new OpenOptions(), result -> {
    AsyncFile file = result.result();
    Observable<Buffer> observable = file.toObservable();
    observable.forEach(data -> System.out.println("Read data: " + data.toString("UTF-8")));
  });
}
 
Example #3
Source File: RxifiedExamples.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
public void unmarshaller(FileSystem fileSystem) {
  fileSystem.open("/data.txt", new OpenOptions(), result -> {
    AsyncFile file = result.result();
    Observable<Buffer> observable = file.toObservable();
    observable.lift(io.vertx.rxjava.core.RxHelper.unmarshaller(MyPojo.class)).subscribe(
        mypojo -> {
          // Process the object
        }
    );
  });
}