I have 3 different types of files in a folder. Every file has same data which is saved into Employee Table.
File Types:
- XML
- Excel
- .txt
I have written 3 separate classes which have two methods, take a filePath as String parameter and return an EmployeeVO Object or a List<EmployeeVO>.
I want to remove these if else.
List<EmployeeVO> list ;
if(fileName.endsWith(".xml")){
list = XmlReader();
}else if(fileName.endsWith(".EXCEL")){
list = ExcelReader();
}else if(fileName.endsWith(".TXT")){
list = TxtReader();
}
You could use a kind of strategy: