'JAVA - Compare value in Excel file with files present in the folder

I have an excel file that I read through org.apache.poi, but I would like to read all the values ​​of column 1 and column 2. If the value in column 1 is equal to the name of the file in the folder then the file must be renamed with the value in column 2 (The value is ever not null).

For ex: File name in a folder X: test

EXCEL |Column 1 | Column 2| |test | newName |

The file in a folder X must be renamed in newName

(Obviously the files are numerous, about 200)

I read the file with this code:

FileInputStream fis = new FileInputStream(file);   //obtaining bytes from the file  
//creating Workbook instance that refers to .xlsx file  
XSSFWorkbook wb = new XSSFWorkbook(fis);   
XSSFSheet sheet = wb.getSheetAt(0);     //creating a Sheet object to retrieve object  
Iterator<Row> itr = sheet.iterator();    //iterating over excel file  
while (itr.hasNext())                 
{  
Row row = itr.next();  
Iterator<Cell> cellIterator = row.cellIterator();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source