This is a Java-based utility for filtering data from input files into separate output files based on data type (integers, floats, strings) with statistics collection.
- Java Version: 17
- Build System: Maven 3.8.6 or later
- Dependencies:
- Apache Commons Lang 3.14.0 (
org.apache.commons:commons-lang3:3.14.0)
- Apache Commons Lang 3.14.0 (
src/main/java/com/example/FileFilterUtility.java: Main application logicpom.xml: Maven configuration fileREADME.md: This instruction file
- Install Java 17:
- Download and install Java 17 from Adoptium.
- Verify installation:
java -version
Download and install Maven 3.8.6 or later from Apache Maven.Verify installation:mvn --version
Clone or download the project from GitHub:git clone https://github.com/nepridumalsore/TestTask.git cd TestTask
Navigate to the project directory and run:Run the following command to build the project and create the JAR file:mvn clean package
The executable JAR will be created in target/TestTask-0.0.1-SNAPSHOT.jar.
Run the utility with the following command:java -jar target/TestTask-0.0.1-SNAPSHOT.jar [options] input_file1 [input_file2 ...]
- -a: Append mode (append data to output files instead of overwriting).
- -s: Short statistics (display only the count of integers, floats, and strings).
- -f: Full statistics (display count, min, max, sum, and average for numbers; count, min/max length for strings).
- -p : Prefix for output file names (e.g., -p sample-creates sample-integers.txt, sample-floats.txt, sample-strings.txt).
- -o : Output directory for result files (e.g., -o output saves files to output/).
Create input files (in1.txt, in2.txt) in the project directory:echo -e "Lorem ipsum dolor sit amet\n45\nПример\n3.1415\nconsectetur adipiscing\n-0.001\nтестовое задание\n100500" > in1.txt echo -e "Нормальная форма числа с плавающей запятой\n1.528535047E-25\nLong\n1234567890123456789" > in2.txt
Run the utility:java -jar target/TestTask-0.0.1-SNAPSHOT.jar -s -a -p sample- in1.txt in2.txt
Expected output:Statistics: Integers: 3 Floats: 3 Strings: 6Check output files:sample-integers.txt:
45 100500 1234567890123456789
sample-floats.txt:3.1415 -0.001 1.528535047E-25sample-strings.txt:Lorem ipsum dolor sit amet Пример consectetur adipiscing тестовое задание Нормальная форма числа с плавающей запятой Long