Skip to content

Foxcapades/jvm-lib-tee-writer

Repository files navigation

K-Deque

jvm lib tee writer docs dokka ff69b4 tee writer

Tee Writer implementation.

A writer that performs actions on a collection of configured underlying writers.

Import

  implementation("io.foxcapades.lib:tee-writer:1.0.0")

Usage

Kotlin
fun main(args: Array<String>) {
  val errFile = File("stderr.txt")

  val writer = TeeWriter(System.err.writer(), errFile.writer())

  writer.write("Hello world!") // Writes to both stderr and the target file
  writer.flush()               // Flushes both underlying writers
  writer.close()               // Closes both underlying writers
}
Java
public static void main(String[] args) throws IOException {
  File errFile = new File("stderr.txt");

  Writer writer = new TeeWriter(
    new PrintWriter(System.err),
    new FileWriter(errFile)
  );

  writer.write("Hello world!"); // Writes to both stderr and the target file
  writer.flush();               // Flushes both underlying writers
  writer.close();               // Closes both underlying writers
}

About

IO Writer that tees to any number of underlying writers.

Resources

License

Stars

Watchers

Forks

Languages