Results for “File operations & integrity”
Small, practical examples. Search by task or narrow things down below.
Load a small properties configuration
Java: Use a Reader to make the configuration character encoding explicit.
Java✓ Tested
Normalize relative path components
Java: Path.normalize removes redundant dot components without accessing the filesystem.
Java✓ Tested
Read compressed text directly
Python: Open gzip data in text mode with an explicit encoding.
Python✓ Tested
Replace a path extension
C#: Path.ChangeExtension transforms a path string without moving or creating a file.
C#✓ Tested
Set owner-only read and write permissions
C++: Replace ordinary permission bits with the requested owner permissions.
C++✓ Tested
Write and read binary bytes
Java: Use the byte-oriented Files methods when text encoding should not be involved.
Java✓ Tested
Write and read bytes without text conversion
C++: Use binary stream modes and check each I/O operation before consuming its result.
C++✓ Tested
Write and read raw bytes
C#: Use the byte-oriented file APIs when no text encoding should be applied.
C#✓ Tested
Chain operations that may return None
Chain operations that may return None in a complete Rust program using the standard library.
Rust✓ Tested
Check the integrity of a gzip stream
Linux Commands: Use gzip -t to verify a compressed file without extracting it.
Linux Commands✓ Tested
Measure a small seekable binary file
C: Seek to the end and inspect ftell, checking both operations for errors.
C✓ Tested
Add a forgotten file to the latest unpublished commit
Git: Stage the missing file before amending without changing the message.
Git✓ Tested