I'm doing a program which can choose a folder with JFileChooser and that in the console shows the name of the files in the folder in an orderly way.
JFileChooser selecto = (JFileChooser) e.getSource();
String comand = e.getActionCommand();
if (comand.equals(JFileChooser.APPROVE_SELECTION)) {
File rutaActual = selecto.getSelectedFile();
File[] archivos = rutaActual.listFiles();
JOptionPane.showMessageDialog(this, "Archivos de la carpeta "+rutaActual.getName()+" renombrados exitosamente ");
String nombreCarpeta = rutaActual.getName();
this.transformar = new Transformador();
for (int i = 0; i < archivos.length; i++) {
System.out.println(archivos[i].getName()+"\n");
}
}
But it turns out that it appears inconsistent in certain cases, such as choosing a folder that contains 12 files with the names of each file, equal to the corresponding place, this shows on screen: (1, 10, 11, 12 , 2, 3, 4, 5, 6, 7, 8, 9) that way I do not know what I could fix in my code to solve my problem.
Any help will be welcome.