Skip to content

Input/Output Library

The @std/io module provides basic file and stream operations in Nubo.

import io from "@std/io"

Reads content from the user.

let name = io.read("Enter your name: ")

io.open(file: string, encoding: string = “utf-8”): IOStream

Section titled “io.open(file: string, encoding: string = “utf-8”): IOStream”

Opens a file stream with optional encoding. Returns a stream object with methods for reading data.

let file = io.open("file.txt")

Returned by io.open(...):

  • read(): string – Reads next chunk.
  • readAll(): string – Reads the entire content.
  • readByte(): int – Reads one byte.
  • readLine(): string – Reads a single line.
  • close(): void – Closes the stream.
let f = io.open("file.txt")
println(f.readLine())
f.close()

These methods are useful for reading files and handling input data in a streaming way.