A Java-based text analysis tool that provides detailed statistical information about text input. This program offers both interactive input and file-based analysis capabilities.
- Multiple input methods:
- Direct keyboard input
- Text file analysis
- Comprehensive text statistics:
- Total character count
- Character count (excluding spaces)
- Word count
- Sentence count
- Average word length
- Results management:
- View results on screen
- Save analysis to timestamped files
- Interactive menu system
- Detailed help documentation
- Java Development Kit (JDK) 8 or higher
- Any operating system (Windows, macOS, Linux)
- Clone or download this repository
- Ensure Java is installed on your system
- Navigate to the project directory
javac TextAnalyzer.javajava TextAnalyzer-
Analyze text from keyboard input
- Type or paste your text
- Type 'END' on a new line when finished
- View analysis results
- Optionally save results to file
-
Analyze text from file
- Enter the path to your text file
- View analysis results
- Optionally save results to file
-
Help
- Display detailed usage instructions
-
Exit
- Close the program
-
Analyzing keyboard input:
1. Select option 1 2. Type or paste your text 3. Type 'END' on a new line 4. View results 5. Choose whether to save results -
Analyzing a file:
1. Select option 2 2. Enter file path (e.g., sample.txt) 3. View results 4. Choose whether to save results
The analysis results include:
- Total character count
- Character count (excluding spaces)
- Word count
- Sentence count
- Average word length (characters per word)
Example output:
=== Analysis Results ===
Total characters: 150
Characters (no spaces): 125
Word count: 30
Sentence count: 3
Average word length: 4.17 characters
When saving results, the program:
- Creates a timestamped file (format: analysis_YYYYMMDD_HHMMSS.txt)
- Includes the original text
- Lists all statistical measurements
- Saves in the current directory
TextAnalyzer.java- Main program filesample.txt- Example text file for testingREADME.md- Documentation (this file)
A sample text file (sample.txt) is included for testing the file analysis feature.
The program handles various error cases:
- Invalid menu selections
- File not found
- Invalid file paths
- Empty text input
- Input/output errors
Feel free to fork this repository and submit pull requests for any improvements.
This project is open source and available for personal and educational use.