Lightweight, dependency-free Java file I/O toolkit for reading, writing, searching, and managing files efficiently.
π File Reading β’ βοΈ File Writing β’ π Text Search β’ π File Management β’ β‘ High Performance
- Single entry point - No more searching through multiple utility classes
- Fluent interface - Chain operations naturally
- Consistent naming - Intuitive method names that make sense
- Pure Java 11+ - No external dependencies to manage
- Lightweight footprint - Minimal impact on your project
- Easy updates - No dependency conflicts or version hell
- Regex-powered search with range limitations
- Line-level operations - insert, delete, modify specific lines
- Safe mode operations - automatic backups before modifications
- Memory-mapped I/O for large file handling
- Customizable buffers for optimal memory usage
- Efficient algorithms for fast search and replace operations
- Recursion protection - prevents accidental directory loops
- Comprehensive validation - catch errors before they happen
- Detailed error messages - know exactly what went wrong
import io.github.raghultech.openloom.OpenLoom;
import java.io.File;
import java.util.List;
import java.util.Map;
public class QuickStart {
public static void main(String[] args) {
OpenLoom loom = new OpenLoom();
// Read files with automatic encoding detection
String content = loom.read().read(new File("data.txt"));
// Write files with safe operations
loom.write().write(new File("output.txt"), "Hello OpenLoom!");
// Advanced text search with regex support
List<String> results = loom.search().findLineRegex(new File("log.txt"), "ERROR.*");
// File management with recursion protection
loom.file().copyDir(new File("source"), new File("backup"), true);
}
}
Category | Description |
---|---|
π§ ReadManager | Read text, metadata, and structured columns with custom buffer size |
βοΈ WriteManager | Write and append, with small and large files safely |
π SearchManager | Find, modify, replace, delete, or insert lines with regex support and safe modes |
π FileManager | Copy, move, create, and delete files or directories |
Problem | Traditional Solution | OpenLoom Solution |
---|---|---|
Complex file search | Manual loops + regex | findLineRegex() + findLineRegexInRange() |
Safe file modifications | Manual backup creation | replaceTextSafe() auto-backup |
Multiple utility classes | Apache Commons IO + custom code | Single OpenLoom entry point |
Dependency management | Multiple JARs | Zero dependencies |
Large file handling | Complex memory management | readMemoryMapped() + readInChunk() |
<dependency>
<groupId>io.github.raghul-tech</groupId>
<artifactId>openloom</artifactId>
<version>1.0.0</version>
</dependency>
implementation 'io.github.raghul-tech:openloom:1.0.0'
import io.github.raghultech.openloom.OpenLoom;
import java.io.File;
import java.util.List;
import java.util.Map;
public class ReadExample {
public static void main(String[] args) {
OpenLoom loom = new OpenLoom();
// Text file reading with various strategies
String content = loom.read().read(file); // Auto strategy
String buffered = loom.read().readBuffered(file, 8192); // Custom buffer
String fast = loom.read().readUsingChannel(file); // NIO channels
// Structured data extraction
List<String[]> columns = loom.read().readColumns(file, ",", new int[]{0, 2});
// File metadata and properties
Map<String, Object> metadata = loom.read().readMetadata(file);
// Stream processing for large files
loom.read().readLines(file, line -> processLine(line));
}
}
import io.github.raghultech.openloom.OpenLoom;
import java.io.File;
public class WriteExample {
public static void main(String[] args) {
OpenLoom loom = new OpenLoom();
// Write new file
loom.write().write(new File("output.txt"), "Hello OpenLoom!");
// Append to existing file
loom.write().append(new File("output.txt"), "\nAdditional content");
// Write with custom bufferSize
loom.write().write(new File("output.txt"), "New content",64*1024);
// Write large files efficiently
loom.write().writeLarge(new File("bigfile.txt"), largeContent);
}
}
import io.github.raghultech.openloom.OpenLoom;
import java.io.File;
import java.util.List;
public class SearchExample {
public static void main(String[] args) {
OpenLoom loom = new OpenLoom();
// Flexible search operations
List<String> results = loom.search().findLine(file, "searchTerm");
List<String> rangeResults = loom.search().findLineInRange(file, "term", 10, 50);
// Regex-powered search capabilities
List<String> regexResults = loom.search().findLineRegex(file, "pattern.*");
List<String> rangeRegex = loom.search().findLineRegexInRange(file, "pattern", 0, 100);
// Content modification with precision
loom.search().replaceText(file, "old", "new");
loom.search().deleteLine(file, 5);
loom.search().insertLine(file, 3, "new content");
// Safe operations with automatic backups
loom.search().replaceTextSafe(file, "old", "new");
}
}
import io.github.raghultech.openloom.OpenLoom;
import java.io.File;
public class FileOpsExample {
public static void main(String[] args) {
OpenLoom loom = new OpenLoom();
// Copy files
loom.file().copyFile(new File("input.txt"), new File("backup/input_copy.txt"));
// Move files
loom.file().moveFile(new File("backup/input_copy.txt"), new File("moved/input.txt"));
// Copy entire directories
loom.file().copyDir(new File("project"), new File("backup/project"), true);
// Move directories
loom.file().moveDir(new File("old_location"), new File("new_location"), true);
// Delete files and directories
loom.file().deleteFile(new File("temp.txt"));
loom.file().deleteDir(new File("old_backup"));
}
}
// Safely update application configurations
OpenLoom loom = new OpenLoom();
loom.search().replaceTextSafe(
new File("application.properties"),
"database.url=localhost",
"database.url=production-db"
);
// Extract insights from application logs
List<String> errors = loom.search().findLineRegex(
new File("application.log"),
"ERROR.*Exception"
);
// Process structured log files
List<String[]> logEntries = loom.read().readColumns(
new File("access.log"),
" ",
new int[]{0, 3, 6} // timestamp, IP, status code
);
// Bulk file operations for data pipelines
loom.file().copyDir(
new File("/data/legacy-system"),
new File("/data/modern-system"),
true
);
// Process data files during migration
List<String[]> customerData = loom.read().readColumns(
new File("customers.csv"), ",",
new int[]{0, 1, 2} // ID, Name, Email
);
// Large-scale text processing
loom.read().readLines(new File("large-document.txt"), line -> {
if (!loom.search().findLineRegex(line, "confidential|secret").isEmpty()) {
processSensitiveLine(line);
}
});
javac -cp openloom-1.0.0.jar ExampleRead.java
Windows:
java -cp .;openloom-1.0.0.jar ExampleRead
Linux/macOS:
java -cp .:openloom-1.0.0.jar ExampleRead
β Ready-to-run examples in the examples/ folder:
-
ExampleRead.java - Comprehensive reading examples
-
ExampleWrite.java - Writing and appending patterns
-
ExampleSearch.java - Search and modification techniques
-
ExampleFile.java - File and directory operations
-
Java 11 or higher
-
Works on all major operating systems
-
No third-party dependencies
-
View all releases on the Releases Page.
-
For a detailed log of all changes, refer to the CHANGELOG.md file.
-
We welcome PRs for:
-
π Bug fixes
-
π New features
-
π§ͺ More examples
-
π Documentation
-
Read the Contributing Guide before starting..
- If you've encountered a bug, please report it by clicking the link below. This will guide you through the bug-reporting process: β‘οΈ Click here to report a bug
- This project is licensed under the Apache License 2.0.
Email: raghultech.app@gmail.com
If OpenLoom helped you, you can support it here β€οΈ
Built with β€οΈ for the Java Community
Making file I/O operations simple and efficient