ZIO-NIO is a ZIO wrapper on Java NIO, an opinionated interface with deep ZIO integration that provides type and resource safety.
ZIO-NIO is available via maven repo. Add this to your dependencies in
libraryDependencies += "dev.zio" %% "zio-nio" % "2.0.0"
- Using Blocking APIs — How to deal with NIO APIs that block the calling thread
- File Channel — For processing files that are available locally. For every operation a new fiber is started to perform the operation.
- Socket Channel — Provides an API for remote communication with
- Resource Management - Avoiding resource leaks
- Character Sets - For encoding or decoding character data.
When reading from channels, the end of the stream may be reached at any time. This is indicated by the read effect failing with an
java.io.EOFException. If you would prefer to explicitly represent the end-of-stream condition in the error channel, use the
eofCheck extension method:
val read100: ZIO[Blocking, Option[IOException], Chunk[Byte]] =
End-of-stream will be signalled with
None. Any errors will be wrapped in