⚡ Scrape and process millions of files in millREADME.md README.md README.md README.md README.md README.md README.md README.md README.md README.md README.mdiseconds with zero latency.
FastFileScrape is the high‑speed file scraping module of the FastJava ecosystem.
It provides two core capabilities:
- FastFileTree — build complete directory trees with include/exclude rules
- FastFileScrapeContent — extract file contents with chunking for LLMs and agents
Watch Demo (YouTube) | Watch JMH Benchmark (Youtube)
import fastfilescrape.*;
import java.nio.file.Path;
import java.util.List;
public class Demo {
public static void main(String[] args) throws Exception {
// 1. FastFileTree — Build and print directory tree
var tcfg = new FastFileTree.Config();
tcfg.root = Path.of(".");
var tree = FastFileTree.build(tcfg);
FastFileTree.printTree(tree, System.out);
// 2. FastFileScrapeContent — Extract chunked contents for LLMs & agents
var ccfg = new FastFileScrapeContent.Config();
ccfg.root = Path.of(".");
ccfg.includeGlobs = List.of("**/*.java");
FastFileScrapeContent.scrape(ccfg, (file, chunk, text) -> {
System.out.println("=== " + file + " (chunk " + chunk + ") ===");
System.out.println(text);
});
}
}# Show directory tree
fastfilescrape tree --root . --include "**/*.java"
# Extract file contents
fastfilescrape content --root . --include "**/*.java" --out repo.txt
# Tree + Content in JSONL
fastfilescrape all --root . --include "**/*.java" --format jsonl --out repo.jsonl- Why FastFileScrape
- Installation
- API Reference
- Documentation
- Platform Support
- License
- Related Projects
Java's standard Files.walk() and Files.readString() work — but they were not designed for scraping millions of files at agent speed.
| Concern | Standard Java | FastFileScrape |
|---|---|---|
| Directory traversal | Files.walk() — JVM syscall per entry |
FastGLOB native Win32 traversal — batch results |
| Glob matching | PathMatcher — regex compiled per match |
FastGLOB native — string contains fast-path first |
| File reading | Sequential, one file at a time | parallelStream() — all files in parallel |
| Exclude checks | Full PathMatcher regex per file |
String contains() fast-path, regex only as fallback |
| LLM chunking | Manual splitting, easy to split mid-token | Built-in UTF-8 boundary-safe 64 KB chunks |
| Size guard | Manual | Configurable maxFileSizeBytes, skips binaries |
When an AI agent needs to read an entire codebase into context — say, 2 000 .java files across 400 folders — standard Java spends most of its time in filesystem overhead and sequential I/O.
FastFileScrape does the traversal natively, filters with a string fast-path, and reads all matching files in parallel. The Sink callback streams chunks directly to the agent pipeline without buffering the entire repo in memory.
Add the JitPack repository and the dependencies to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastFileScrape</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastGLOB</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>v1.0.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastFileScrape:0.1.0'
implementation 'com.github.andrestubbe:FastGLOB:0.1.0'
implementation 'com.github.andrestubbe:FastCore:v1.0.0'
}Download the pre-compiled JARs to add them to your classpath:
- 📦 FastFileScrape-0.1.0.jar (The Scraper Core Library)
- 📦 FastGlob-0.1.0.jar (The Native Glob Matching Library)
- ⚙️ fastcore-v1.0.0.jar (The Mandatory JNI Loader)
Important
Since FastFileScrape is natively accelerated, all three JARs must be present in your classpath for the JNI-accelerated directory walking to operate correctly on Windows.
| Method | Description |
|---|---|
Node build(Config cfg) |
Builds the directory tree |
printTree(Node, Appendable) |
Prints ASCII tree |
| Method | Description |
|---|---|
scrape(Config cfg, Sink sink) |
Reads files and emits chunks |
- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API descriptions, border configurations, and codepoint index.
- PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
- ROADMAP.md: Future milestones and planned features.
| Platform | Status |
|---|---|
| Windows 10/11 | ✅ Fully Supported |
| Linux | 🚧 Planned |
| macOS | 🚧 Planned |
MIT License — See LICENSE file for details.
- FastFileIndex — Ultra-fast filesystem scanner
- FastFileContentIndex — High-speed in-file text indexing
- FastFileWatch — High-performance directory watch service using USN Journal
- FastFileSearch — Ultra-fast indexed file prefix trie search
- FastGLOB — Ultra-fast native Win32 glob matching and traversal
- FastFileSystem — Unified filesystem operations (Index, Search, Watch, Scrape) in one API
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋
