Skip to content

raghul-tech/OpenLoom

🧡 OpenLoom - Modern Java File I/O Library

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

Maven Central Build Status CodeQL Security Javadoc Latest Release Buy Me A Coffee


🎯 Why Developers Choose OpenLoom

πŸš€ Modern API Design

  • Single entry point - No more searching through multiple utility classes
  • Fluent interface - Chain operations naturally
  • Consistent naming - Intuitive method names that make sense

πŸ“¦ Zero Dependency Architecture

  • Pure Java 11+ - No external dependencies to manage
  • Lightweight footprint - Minimal impact on your project
  • Easy updates - No dependency conflicts or version hell

πŸ” Advanced Search Capabilities

  • Regex-powered search with range limitations
  • Line-level operations - insert, delete, modify specific lines
  • Safe mode operations - automatic backups before modifications

⚑ Performance Optimized

  • Memory-mapped I/O for large file handling
  • Customizable buffers for optimal memory usage
  • Efficient algorithms for fast search and replace operations

πŸ›‘οΈ Built-in Safety

  • Recursion protection - prevents accidental directory loops
  • Comprehensive validation - catch errors before they happen
  • Detailed error messages - know exactly what went wrong

⚑ Quick Start

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);
    }
}

πŸš€ Features Overview

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

🎯 Solve Common Java File I/O Challenges

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()

πŸ“¦ Installation

Maven

<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>openloom</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

implementation 'io.github.raghul-tech:openloom:1.0.0'

πŸš€ Complete Feature Set

🧠 ReadManager - Comprehensive File Reading

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));
    }
}

✍️ WriteManager - Reliable File Writing

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);
    }
}

πŸ” SearchManager - Powerful Text Operations

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");
    }
}

πŸ“‚ FileManager - Robust File System Operations

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"));
    }
}

πŸ’‘ Ideal For These Use Cases

πŸ”§ Configuration Management Systems

// Safely update application configurations
OpenLoom loom = new OpenLoom();
loom.search().replaceTextSafe(
    new File("application.properties"), 
    "database.url=localhost", 
    "database.url=production-db"
);

πŸ“Š Log Processing & Analysis

// 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
);

πŸ—‚οΈ Data Migration & ETL Process

// 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
);

πŸ“ Document Processing Workflows

// Large-scale text processing
loom.read().readLines(new File("large-document.txt"), line -> {
   if (!loom.search().findLineRegex(line, "confidential|secret").isEmpty()) {
        processSensitiveLine(line);
    }
});

πŸ’‘ Run Using JAR

🧡 Compile:

javac -cp openloom-1.0.0.jar ExampleRead.java

▢️ Run:

Windows:

java -cp .;openloom-1.0.0.jar ExampleRead   

Linux/macOS:

java -cp .:openloom-1.0.0.jar ExampleRead   

πŸ“‚ Example Files

βœ… Ready-to-run examples in the examples/ folder:


🧩 Requirements

  • Java 11 or higher

  • Works on all major operating systems

  • No third-party dependencies


πŸ†• Changelog:


🀝 Contributing

  • We welcome PRs for:

    • πŸ› Bug fixes

    • πŸš€ New features

    • πŸ§ͺ More examples

    • πŸ“ Documentation

Read the Contributing Guide before starting..


🐞 Report a Bug

  • 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

πŸ“„ License


πŸ“¬ Contact

Email: raghultech.app@gmail.com


β˜• Support

If OpenLoom helped you, you can support it here ❀️

Buy Me A Coffee


Built with ❀️ for the Java Community
Making file I/O operations simple and efficient