boas,
a função abaixo, supostamente, devia renomear os ficheiros de um arquivo. mas dá sempre erro ao renomear, e não estou a ver qual o problema. alguém tem sugestões? obrigado
saudações
public static void main(String []args){
String opcao = "";
System.out.println("Qual o directorio?");
opcao = read();
File dir = new File(opcao);
String[] lista = dir.list();
if (lista == null) {
} else {
for (int i=0; i<lista.length; i++) {
File file = new File(lista[i].toString());
String newname = "AD." + e.getExtencao();
File file2 = new File(newname);
System.out.println(file2);
boolean success = file.renameTo(file2);
if (!success) {
System.out.println("Erro");
}
else System.out.println("Success");
}
}
}


