Code Explainers
Code explainers tagged #file-io
java
@GetMapping("/files/{id}") public ResponseEntity<StreamingResponseBody> download( @PathVariable String id, @RequestHeader(value = HttpHeaders.RANGE, required = false) String rangeHeader) throws IOException {
HTTP range requests in Spring
http-range
streaming
file-io
Advanced
10 steps
rust
use std::collections::BTreeSet; use std::fs::File; use std::io::{self, BufRead, BufReader, BufWriter, Write}; use std::path::Path;
Deduplicating and sorting words in Rust
file-io
btreeset
string-processing
Intermediate
6 steps
java
public final class BomAwareReader { private static final char UTF8_BOM = '\uFEFF';
Skipping the UTF-8 byte-order mark in Java
file-io
encoding
byte-order-mark
Intermediate
6 steps
python
import wave import os from dataclasses import dataclass
Reading WAV metadata into a dataclass
dataclass
audio
file-io
Beginner
5 steps
java
public class DuplicateFinder { public Map<String, List<Path>> findDuplicates(Path root) throws IOException { Map<String, List<Path>> byHash = new HashMap<>();
Finding duplicate files by content hash
hashing
file-io
streams
Intermediate
8 steps
rust
use std::collections::HashMap; use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path;
Parsing INI files in Rust
parsing
file-io
hashmap
Intermediate
9 steps
python
from pathlib import Path from PIL import Image, ImageOps
Batch image resizing with Pillow
image-processing
batch-jobs
error-handling
Intermediate
8 steps
python
from pathlib import Path import chardet
Reading text files of unknown encoding in Python
encoding
byte-order-mark
fallback
Intermediate
8 steps
java
package com.example.inventory; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser;
Reading and writing CSV with Commons CSV
csv-parsing
file-io
try-with-resources
Intermediate
7 steps
python
import os import tarfile from pathlib import Path
Safely compressing and extracting tar.gz archives
file-io
compression
path-traversal
Intermediate
6 steps
java
public final class ZipExtractor { private final Path targetDir;
Extracting a zip safely in Java
path-traversal
streams
file-io
Intermediate
8 steps
rust
use std::fs; use std::path::Path; use regex::Regex;
Redacting emails in a file with Rust
regex
file-io
closures
Intermediate
6 steps
rust
use std::fs::{File, OpenOptions}; use std::io::{self, Write}; use std::path::Path;
A buffered log writer in Rust
buffering
raii
file-io
Intermediate
9 steps
java
import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.http.HttpClient;
Streaming a file download with Java's HttpClient
http-client
streaming
file-io
Intermediate
6 steps
python
import csv from pathlib import Path
Splitting a large CSV into smaller files
file-io
streaming
csv
Intermediate
8 steps
python
import hashlib from pathlib import Path
Streaming SHA-256 checksums in Python
hashing
file-io
streaming
Intermediate
6 steps
rust
use std::fs::File; use std::io::{self, BufWriter}; use std::path::Path;
Serializing config to JSON in Rust
serialization
serde
file-io
Intermediate
7 steps
java
package com.example.fs; import java.io.IOException; import java.nio.file.FileSystems;
Watching a directory with Java NIO
file-io
event-loop
resource-management
Intermediate
8 steps