FIND YOUR NEXT FEW LINES

Results for “File operations & paths”

Small, practical examples. Search by task or narrow things down below.

946 snippets foundClear filters
C++Files & paths

Read a file line by line

Read C++ text lines without loading the whole file at once.

C++✓ Tested
C++Files & paths

Read a filename extension

Extract the final extension from a C++ filesystem path.

C++✓ Tested
PythonFiles & paths

Read a text file

Open a UTF-8 text file and read its contents. A context manager closes the file automatically, even if reading fails.

file✓ Tested
C#Files & paths

Read a text file

Load a small text file into a C# string.

C#✓ Tested
JavaFiles & paths

Read a UTF-8 file

Read a small UTF-8 file into a Java string.

Java✓ Tested
PowerShellFiles & paths

Read a whole text file

Load text as one string instead of one item per line.

Get-Content✓ Tested
GitRestoring & revising local work

Remove only a named untracked scratch file

Git: Use a narrow pathspec after reviewing the dry run; clean cannot recover untracked content.

Git✓ Tested
GitStashing selected work

Stash edits to one chosen file

Git: A pathspec limits the stash to selected paths while other changes remain in the working tree.

Git✓ Tested
PythonFiles & paths

Write a text file

Save a string to a UTF-8 text file and close the file automatically when the write finishes.

file✓ Tested
C#Files & paths

Write a text file

Write a C# string to a UTF-8 file.

C#✓ Tested
C++Files & paths

Write a text file

Write and close a C++ output file while checking stream failure.

C++✓ Tested
JavaFiles & paths

Write a UTF-8 file

Write a Java string to a file using an explicit text encoding.

Java✓ Tested