jayo-core
module makes I/O on the JVM easier by providing you a deliberately reduced range of powerful tools.
It is based on the amazing Okio library [1], but does not preserve strict backward compatibility with it, and has been
fully rewritten in Java.
It also contains some naming, designs and documentation from the great kotlinx-io library [2].
[1] : Okio is a very nice Kotlin multiplatform IO library !
[2] : kotlinx-io is a simplified and optimized fork of Okio that targets
exclusively Kotlin, with multiplatform support.
Buffer
is a mutable sequence of bytes one can easily write to and read from. It works like a Queue and will automatically grow when you write data to its end, and shrink when you read data from the start.ByteString
is an immutable and serializable sequence of bytes that stores a String related binary content as-is. You can encode or decode it as hex, base64, and UTF-8, you can also search content in it, build substring and much more.Utf8
is aByteString
that contains UTF-8 encoded bytes only.
Buffer relies on a queue of memory segments. It is optimized fo zero-copy segment sharing with other buffers and uses
pooled byte[]
based segments to avoid GC churn and zero-fill of the memory.
RawReader
and RawWriter
, although conceptually identical, offer great improvements over InputStream
and
OutputStream
- Create a
RawReader
for reading from or aRawWriter
for writing to a file or a network socket, then just obtain a bufferedReader
or aWriter
from it. With them, you have access to feature rich interfaces that provide all the features we offer, yet remaining relatively light with a few dozen useful functions. Reader
andWriter
are all you need ; wether you manipulate Strings, ByteStrings, numbers, pure binary content and so on. No more specific readers needed here.RawReader
andRawWriter
are reasonably easy to implement, feel free to try it !
Define cancellable code blocks thanks to our cancellable builders (like Cancellable.withTimeout(..)
,
Cancellable.executeCancellable(..)
, etc.) that creates a CancelScope
implementation called a CancelToken that is
bound to the current thread thanks to ThreadLocal or Scoped Values, and will automatically propagate cancellation and
timeouts to inner children threads, if any.
The CancelToken will only apply inside its associated code block, and will be removed when the code block has ended.
TlsEndpoint
is a TLS (Transport Layer Security) endpoint over a TLS connection.
It delegates all cryptographic operations to the standard Java TLS/SSL implementation: SSLEngine
; effectively hiding
it behind an easy-to-use streaming API based on Jayo's reader and writer, that allows to secure JVM applications with
minimal added complexity.
It is based on the awesome TLS Channel library [1].
JssePlatform
eases access to platform-specific Java Secure Socket Extension (JSSE) features.
[1] : TLS Channel is a library that implements a ByteChannel
interface over a
TLS (Transport Layer Security) connection.