io library

💾 Jetleaf I/O Subsystem: Streams, Buffers & Functional Topologies

This library provides a unified, cross-platform input/output (I/O) architecture and functional streaming pipeline for the Jetleaf framework.

Key capabilities:


🌊 I/O Stream Hierarchy

┌─────────────────────────────────────────────────────────────┐
│                     Input & Output Streams                  │
├──────────────────────────────┬──────────────────────────────┤
│ Byte Streams (Input/Output)  │ Character Streams (Read/Write)│
├──────────────────────────────┼──────────────────────────────┤
│ • FileInputStream            │ • FileReader / FileWriter    │
│ • ByteArrayInputStream       │ • StringReader               │
│ • BufferedInputStream        │ • BufferedReader             │
│ • NetworkInputStream         │ • BufferedWriter             │
└──────────────────────────────┴──────────────────────────────┘

📦 Exports Categorization

📥 Byte Input Streams

📤 Byte Output Streams

📖 Readers & Writers

  • Reader, Writer — abstract character stream abstractions.
  • BufferedReader — reads text from a character-input stream, buffering characters for efficient reading of lines.
  • BufferedWriter — writes text to a character-output stream with internal buffering.

⚡ Functional Streams

  • BaseStream — base interface for functional streams.
  • GenericStream — typed stream supporting transformation pipelines.
  • StreamBuilder — builder for constructing streaming pipelines.

🎯 Usage Example: Functional Stream Processing

import 'package:jetleaf_core/io.dart';

void main() {
  // Build a functional stream from memory
  final stream = StreamBuilder.of<String>(['dart', 'jetleaf', 'backend', 'aot'])
      .filter((s) => s.length > 3)
      .map((s) => s.toUpperCase());

  final results = stream.toList();
  print('Filtered results: $results');
  // Output: ['DART', 'JETLEAF', 'BACKEND']
}

Classes

BaseStream<T, S extends BaseStream<T, S>>
Base interface for streams, which are sequences of elements supporting sequential and parallel aggregate operations.
BufferedInputStream
A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark and reset methods.
BufferedOutputStream
The class implements a buffered output stream.
BufferedReader
Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.
BufferedWriter
Writes text to a character-output stream, buffering characters to provide efficient writing of characters, arrays, and strings.
ByteArrayInputStream
A byte-based input stream that reads from a Uint8List buffer.
ByteArrayOutputStream
An OutputStream that writes to a growable internal byte buffer.
Closeable
An object that may hold resources until it is closed.
ConsolePrintStream
A concrete implementation of PrintStream that writes to the console using stdout.
DoubleStream
A sequence of primitive double-valued elements supporting sequential and parallel aggregate operations.
FileInputStream
A FileInputStream obtains input bytes from a file in a file system.
FileOutputStream
A file output stream is an output stream for writing data to a File or to a file descriptor.
FileReader
Convenience class for reading character files.
FileWriter
Convenience class for writing character files.
Flushable
An object that can be flushed.
GenericStream<T>
A sequence of elements supporting sequential and parallel aggregate operations.
InputStream
This abstract class is the superclass of all classes representing an input stream of bytes.
InputStreamSource
A simple interface for objects that provide an InputStream.
IntStream
A sequence of primitive int-valued elements supporting sequential and parallel aggregate operations.
NetworkInputStream
An InputStream implementation that reads bytes from a Dart Stream<List<int>>.
NetworkOutputStream
An OutputStream implementation that writes bytes to a Dart HttpClientRequest.
OutputStream
This abstract class is the superclass of all classes representing an output stream of bytes.
PrintStream
An abstract interface representing a stream for formatted text output.
Reader
Abstract class for reading character streams.
Runnable
A simple contract for objects that can be executed.
SinkOutputStream
A concrete implementation of OutputStream that wraps a Dart IOSink, allowing byte, list of bytes, and string data to be written to any underlying sink, such as files, sockets, or stdout.
StandardDoubleStream
Private implementation of DoubleStream that wraps an Iterable of doubles.
StandardGenericStream<T>
Implementation of GenericStream that wraps an Iterable and provides some basic stream operations.
StandardIntStream
Private implementation of IntStream.
StreamBuilder<T>
A mutable builder for a GenericStream.
StreamSupport
Low-level utility methods for creating and manipulating streams.
StringInputStream
A character-based input stream backed by an encoded String.
StringReader
A Reader implementation that reads characters from a String buffer.
Writer
Abstract class for writing to character streams.