Example usage for java.util.stream Stream onClose

List of usage examples for java.util.stream Stream onClose

Introduction

In this page you can find the example usage for java.util.stream Stream onClose.

Prototype

S onClose(Runnable closeHandler);

Source Link

Document

Returns an equivalent stream with an additional close handler.

Usage

From source file:com.themodernway.server.core.io.IO.java

public static final Stream<String> lines(final Reader reader, final boolean greedy) throws IOException {
    final Stream<String> lines = IO.toBufferedReader(reader).lines();

    if (greedy) {
        return CommonOps.toList(lines.onClose(IO.onClose(reader))).stream();
    }/*from  w ww  .  ja va 2 s .c  o m*/
    return lines;
}