Input/Output Library
The @std/io
module provides basic file and stream operations in Nubo.
Importing
Section titled “Importing”import io from "@std/io"
Functions
Section titled “Functions”io.read(text: string): string
Section titled “io.read(text: string): string”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")
IOStream Methods
Section titled “IOStream Methods”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.
Example
Section titled “Example”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.