This small Java project serves as a practice exercise to explore basic file operations, exception handling, and data manipulation in Java. The application reads from a simple text file containing details of individuals, processes the information, and performs basic filtering based on criteria.
- Reading Data: The application reads data from
people.txtusingFileHelper, which stores each line as a string in a list. - Data Conversion:
PersonOperationHelperconverts these string entries intoPersonobjects, using a custom format specified in the text file. - Error Handling: Implements custom exception handling for data conversion errors, particularly focusing on salary values.
- Data Filtering: The
Mainclass includes a method to filterPersonobjects based on surname start, sex, and a limit to the number of results.
To run this application, compile and execute the Main.java. It requires no command line arguments but will automatically process data as per the hardcoded logic in the main method.
- src/com/company/Main.java: Contains the
mainmethod that orchestrates the reading of data from a file, processing it intoPersonobjects, and filtering based on specific attributes. - src/First/FileHelper.java: Handles reading lines from a file and storing them in a list.
- src/First/InvalidSalaryException.java: Custom exception class for handling invalid salary data.
- src/First/Person.java: Data model class representing an individual with attributes like name, surname, age, city, salary, and sex.
- src/First/PersonOperationHelper.java: Provides functionality to convert lines of text into
Personobjects. - src/First/people.txt: Text file containing semi-colon separated values representing people.
Files:
- 📁 src
- 📁 com
- 📁 company
Main.java
- 📁 company
- 📁 First
FileHelper.javaInvalidSalaryException.javapeople.txtPerson.javaPersonOperationHelper.java
- 📁 com