# square/okio

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/square-okio).**

8,986 stars · 1,216 forks · Kotlin · apache-2.0

## Links

- GitHub: https://github.com/square/okio
- Homepage: https://square.github.io/okio/
- awesome-repositories: https://awesome-repositories.com/repository/square-okio.md

## Topics

`kotlin` `kotlin-multiplatform`

## Description

Okio is a Java I/O library providing a set of tools for efficient byte-stream processing and file system operations. It functions as a buffered byte stream handler and streaming data transformer, utilizing a cross-platform file system API to manage data movement.

The project is distinguished by its use of pooled mutable byte buffers that treat sequences as queues to reduce memory copying and garbage collection churn. It further decouples file operations from the host operating system through an abstraction-based file system, allowing for consistent path manipulation and atomic operations across Windows and Unix systems, as well as the ability to treat ZIP archives as read-only file systems.

The library covers a broad range of capabilities including cryptographic data integrity via real-time stream hashing and encryption, and data compression using Gzip and Deflate algorithms. It also provides network socket communication and in-memory file system simulation for mocking I/O operations during testing.

## Tags

### Operating Systems & Systems Programming

- [File System Operations](https://awesome-repositories.com/f/operating-systems-systems-programming/system-administration-maintenance/file-system-management/file-system-operations.md) — Provides a unified cross-platform interface for atomic file operations and path manipulation across Windows and Unix.
- [Cross-Platform Asynchronous I/O Abstractions](https://awesome-repositories.com/f/operating-systems-systems-programming/cross-platform-asynchronous-i-o-abstractions.md) — Provides a unified interface for performing consistent file and disk operations across different operating systems.
- [File I/O Management](https://awesome-repositories.com/f/operating-systems-systems-programming/file-i-o-management.md) — Provides a comprehensive set of Java tools for efficient byte-stream processing and file system operations.
- [File System Access](https://awesome-repositories.com/f/operating-systems-systems-programming/file-system-access.md) — Provides a consistent interface for reading and writing files across multiple platforms for disk operations. ([source](https://square.github.io/okio/multiplatform/))
- [In-Memory Byte Stream Processing](https://awesome-repositories.com/f/operating-systems-systems-programming/in-memory-byte-stream-processing.md) — Implements memory-efficient byte stream processing using pooled arrays to minimize garbage collection overhead. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffer/index.html))
- [Mutable Byte Buffers](https://awesome-repositories.com/f/operating-systems-systems-programming/in-memory-byte-stream-processing/mutable-byte-buffers.md) — Manages bytes as growable queues to significantly reduce memory copying and GC churn during I/O. ([source](https://square.github.io/okio/))
- [Zip Archive Access](https://awesome-repositories.com/f/operating-systems-systems-programming/file-system-access/zip-archive-access.md) — Provides the ability to treat ZIP archives as read-only file systems for streamlined internal content access. ([source](https://square.github.io/okio/3.x/okio/okio/okio/))
- [Immutable Byte Sequences](https://awesome-repositories.com/f/operating-systems-systems-programming/immutable-byte-sequences.md) — Provides immutable byte sequences to optimize memory usage and simplify comparisons during stream processing. ([source](https://square.github.io/okio/))
- [Data Stream Compression](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/system-programming-primitives/system-primitives/data-stream-compression.md) — Compresses or decompresses data using Gzip and Deflate algorithms during stream read and write operations. ([source](https://square.github.io/okio/3.x/okio/okio/okio/))

### Data & Databases

- [Queue-Based Buffers](https://awesome-repositories.com/f/data-databases/data-buffering/binary-data-buffers/queue-based-buffers.md) — Treats byte sequences as a growable queue that allows shifting data between buffers without copying memory.
- [I/O Stream Managers](https://awesome-repositories.com/f/data-databases/data-buffering/buffered-input-output-managers/i-o-stream-managers.md) — Provides streamlined interfaces to read from and write to files, paths, and other input/output streams. ([source](https://square.github.io/okio/3.x/okio/okio/okio/))
- [Streaming I/O](https://awesome-repositories.com/f/data-databases/data-i-o/streaming-i-o.md) — Provides a consistent interface for reading byte streams from network, storage, or memory buffers. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-source/index.html))
- [Stream Transformations](https://awesome-repositories.com/f/data-databases/stream-transformations.md) — Applies real-time decompression, encryption, or hashing to data as it is read from or written to a stream.
- [Write Compression](https://awesome-repositories.com/f/data-databases/data-compression-algorithms/write-compression.md) — Compresses output using Gzip or Deflate algorithms as data is written to a sink. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-sink/index.html))
- [Atomic File Operations](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-management-governance/data-integrity-validation/data-integrity/atomic-file-operations.md) — Executes high-level system tasks like atomic moves and metadata retrieval to leverage OS-level efficiencies. ([source](https://square.github.io/okio/file_system/))
- [Streaming Data Transformers](https://awesome-repositories.com/f/data-databases/data-i-o/streaming-i-o/streaming-data-transformers.md) — Implements a pipeline for performing real-time Gzip compression, encryption, and cryptographic hashing on I/O streams.
- [In-Memory File Systems](https://awesome-repositories.com/f/data-databases/file-management-systems/in-memory-file-systems.md) — Ships a simulated in-memory file system for testing I/O operations without performing actual disk writes.

### Networking & Communication

- [General Write Buffering](https://awesome-repositories.com/f/networking-communication/socket-stream-writing/general-write-buffering.md) — Batches small writes into internal buffers to reduce the performance penalty of frequent I/O operations. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-sink/index.html))
- [Socket Networking](https://awesome-repositories.com/f/networking-communication/socket-networking.md) — Enables reading and writing buffered data over network sockets to manage communication timing and timeouts efficiently.

### Programming Languages & Runtimes

- [Stream Adaptation Layers](https://awesome-repositories.com/f/programming-languages-runtimes/stream-adaptation-layers.md) — Maps standard library input and output streams to a unified source and sink API for consistent data handling.
- [Gzip Decompression](https://awesome-repositories.com/f/programming-languages-runtimes/data-compression-and-decompression/gzip-decompression.md) — Automatically decompresses Gzip-encoded content while reading from a data source. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-source/index.html))
- [Hash Context Initializers](https://awesome-repositories.com/f/programming-languages-runtimes/hashing-implementations/hash-context-initializers.md) — Provides the infrastructure to calculate hashes or MACs of data as it is streamed. ([source](https://square.github.io/okio/3.x/okio/okio/okio/))

### Software Engineering & Architecture

- [Byte Buffer Pooling](https://awesome-repositories.com/f/software-engineering-architecture/byte-buffer-pooling.md) — Manages byte arrays in a shared pool to reuse memory and reduce garbage collection overhead during I/O.
- [File System Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/file-system-abstractions.md) — Provides interfaces that decouple high-level file operations from the underlying storage, supporting disk, ZIP, and in-memory systems.
- [Memory Buffering](https://awesome-repositories.com/f/software-engineering-architecture/memory-buffering.md) — Manages byte buffers and streams with pooled memory to reduce garbage collection and improve I/O performance.
- [Stream Decorators](https://awesome-repositories.com/f/software-engineering-architecture/stream-decorators.md) — Wraps basic data streams in decorators to perform real-time decompression, encryption, or hashing during read and write.
- [Byte Sequence Searching](https://awesome-repositories.com/f/software-engineering-architecture/byte-sequence-searching.md) — Locates the index of specific byte sequences within a stream by dynamically expanding internal buffers. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-source/index.html))
- [Path Normalizers](https://awesome-repositories.com/f/software-engineering-architecture/runtime-path-resolvers/path-normalizers.md) — Resolves and transforms file paths by abstracting Windows and UNIX naming conventions into a single internal representation.
- [Streaming Data Transformations](https://awesome-repositories.com/f/software-engineering-architecture/streaming-data-transformations.md) — Layers sources to perform real-time operations such as decompression, decryption, or hashing as data is read. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-sink/index.html))

### Development Tools & Productivity

- [Cross-Platform Path Manipulation](https://awesome-repositories.com/f/development-tools-productivity/cross-platform-path-manipulation.md) — Handles both Windows and UNIX path styles regardless of the host operating system. ([source](https://square.github.io/okio/file_system/))

### Security & Cryptography

- [Cryptographic Hash Verifiers](https://awesome-repositories.com/f/security-cryptography/cryptographic-hash-verifiers.md) — Calculates cryptographic hashes or message authentication codes in real-time during the write process. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-sink/index.html))
- [Data Encryption](https://awesome-repositories.com/f/security-cryptography/data-encryption.md) — Encrypts data using block ciphers while writing it to a destination sink. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-sink/index.html))
- [HMAC Generation](https://awesome-repositories.com/f/security-cryptography/hmac-generation.md) — Computes HMACs using various hash algorithms to ensure the integrity and authenticity of streaming data. ([source](https://square.github.io/okio/multiplatform/))
- [Input Stream Decryption](https://awesome-repositories.com/f/security-cryptography/message-decryption/input-stream-decryption.md) — Automatically decrypts content using a specified cipher during the reading process from a data source. ([source](https://square.github.io/okio/3.x/okio/okio/okio/-buffered-source/index.html))
- [Stream Encryption and Decryption](https://awesome-repositories.com/f/security-cryptography/privacy-data-protection/data-encryption/end-to-end-encryption/media-encryption/stream-encryption-and-decryption.md) — Provides a pipeline for real-time encryption and decryption of data as it is read or written. ([source](https://square.github.io/okio/recipes/))
- [Cryptographic Hash Computations](https://awesome-repositories.com/f/security-cryptography/security/cryptography-and-secrets/cryptographic-primitives-management/cryptographic-hash-computations.md) — Computes cryptographic hashes and MACs for streaming data to verify content integrity and detect tampering.
- [Automatic Stream Encryption](https://awesome-repositories.com/f/security-cryptography/stream-ciphers/automatic-stream-encryption.md) — Automatically encrypts or decrypts data in real-time as it is read from or written to a stream. ([source](https://square.github.io/okio/3.x/okio/okio/okio/))

### Testing & Quality Assurance

- [File System Mocking](https://awesome-repositories.com/f/testing-quality-assurance/file-system-mocking.md) — Allows verifying file operations using a fake implementation to avoid modifying actual disk storage during tests. ([source](https://square.github.io/okio/file_system/))
