Sto facendo un programmino che deve rinominare dei file .png (il file è nominato come codice.png9) di una certa directory prendendo i dati da un file .xls (che contiene oltre al codice, altre info che devo andare ad aggiungere al nome del file .png).
Ho pensato di mettere la lista dei file .png in un file .txt e poi memorizzare i nomi in un array di stringhe.
Quindi per ogni riga del file .xls controllo la presenza del codice nell'array e se è presente rinomino il file altrimenti stampo a schermo codice + nome.
Cosa ne pensate della mia soluzione?

Ecco il mio codice:
codice:
private static String nome;
	
	public static void main(String args[]) throws IOException, FileNotFoundException {
		
		String userList = "C:/......./lista.txt";
		
		File fileTxt = new File(userList);
		FileReader fr = new FileReader(fileTxt);
		BufferedReader br = new BufferedReader(fr);
		ArrayList<String> aS = new ArrayList<String>();
		String s = br.readLine();
	
		while (s!=null){
			aS.add(s);
			s = br.readLine();
		}
		String[] arrayDiStringhe = aS.toArray(new String[0]);
		
		br.close();

		try {
			// Directory che contiene il file xls da analizzare
			String path = "C:/...../NEW/";
			// Apre il file Excel
			Workbook wb = new HSSFWorkbook(new FileInputStream(path.concat("Voti.xls")));
			// Si posiziona sullo sheet numero 0 (il primo)
			Sheet sheet = wb.getSheetAt(0);
			// Iteratore per le righe del foglio
			Iterator rows = sheet.rowIterator();
			String codice = new String();

			// Iteriamo su tutte le righe del foglio
			while( rows.hasNext() ) { 
				HSSFRow row = (HSSFRow) rows.next();
				row.cellIterator();
				// Partiamo dalla riga numero 1
				if (row.getRowNum() >= 1 ) {	
					codice = row.getCell(0).toString().trim();
//					System.out.println(row.getCell(2) + "-" + row.getCell(3) + "-" + codice);
					
					//Ciclo sull'array dei nomi
					for (int i=0; i<arrayDiStringhe.length; i++){		    	
						//Memorizzo il nome dell'i-esima stringa del file txt
						nome = arrayDiStringhe[i].trim().substring(0, 7);
						nome.concat(".0");
						if(nome.equals(codice)){
//							File dirOutput = new File(path.concat("//").concat(row.getCell(2).toString())
//									.concat(" - ").concat(row.getCell(3).toString())
//									.concat(" - ").concat(codice).concat(".png"));
							System.out.println("Trovato: " + codice + " - " + row.getCell(3));
						}
						else{
							System.out.println("NON Trovato: " + codice + " - " + row.getCell(3));
						}
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	} // chiusura main
Il mio problema è che l'IF tra i 2 codici fallisce sempre....sapete aiutarmi?