#read Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Go Read File — Whole / Lines / Bytes
Three common patterns: load it all (`os.ReadFile`), iterate line-by-line with `bufio.Scanner`, or stream chunks via `io.Reader`. Pick by file size.
Bash Read File Line-By-Line (the safe way)
The classic `for line in $(cat file)` is wrong — it word-splits and globbing fires on filenames. Use `while IFS= read -r line` with input redirection.
Bash Read Single Keystroke Without Enter
For menus and confirm prompts where you want one-key response (no need to press Enter). -n 1 reads exactly one character, -s silences the echo.
Java Files.readString / readAllLines
`java.nio.file.Files` shipped these convenience helpers in Java 8/11. Way cleaner than the legacy `FileReader` + `BufferedReader` ceremony for small/medium files.
Kotlin Read a File — Whole, Lines, or Stream
Stdlib extensions on `java.io.File` and `java.nio.file.Path`. Use `readText()` for small files, `useLines { }` for memory-efficient line-by-line.
Rust Read a File — Whole / Lines / Bytes
Three common patterns: load it all into memory, iterate line-by-line, or stream bytes. Pick by file size — `read_to_string` is convenient but bad for huge files.