This project is a multithreaded text file analyzer built with Java 21 and virtual threads (Project Loom). It scans a directory for .txt
files, analyzes each file concurrently, and generates a summary report. Each file's analysis includes line counts, word counts, keyword hits, top words, and last modified timestamp.
Each .txt
file is processed in parallel using virtual threads. The results include statistics like word and line counts, detected keywords (e.g., "error", "fail", "exception"), and the top 3 most frequent words (excluding common stop words).
- Analyzes
.txt
files in a given directory - Processes each file in a separate virtual thread
- Extracts line and word count
- Counts keyword occurrences (e.g., error, fail, warning, exception)
- Detects top 3 most frequent non-common words
- Records last modified timestamp of each file
- Displays a full report of results
- Java 21
- Project Loom (Virtual Threads)
- Java NIO (
Path
,Files
,DirectoryStream
) - Collections (
Map
,List
,Set
) - Streams API
- Java 21 or higher
- IntelliJ IDEA or any Java-compatible IDE
-
Clone the repository:
git clone https://github.com/your-username/java-fundamentals-file-processor.git
-
Navigate to the project directory:
cd java-fundamentals-file-processor
-
Create a
samples
folder in the root directory and add.txt
files to it. -
Compile the code:
javac -d bin src/com/fileprocessor/**/*.java
-
Run the program:
java -cp bin com.fileprocessor.Main
When you run the app, it scans the samples/
folder for .txt
files. Each file is analyzed for:
- Line and word count
- Predefined keywords
- Top 3 most frequent meaningful words
- Last modified time
A summary is printed in the console.
java-fundamentals-file-processor/
├── samples/ # Place .txt files here
├── src/
│ └── com/
│ └── fileprocessor/
│ ├── Main.java
│ ├── model/
│ │ └── FileAnalysisResult.java
│ ├── service/
│ │ └── FileAnalyzer.java
├── README.md
This project is licensed under the MIT License.