Evaluate the existence of the type of extensions within an ArrayList [closed]

1

I need to evaluate the file content of a ArrayList<String> called ArrayArchives , which contains the files raised by extension of a specific address, which I do to raise those extensions.

     public void buscarArchivo(File ruta) {
            //        Creo el vector que contendra todos los archivos de una ruta especificada.
                    File[] archivo = ruta.listFiles();
            //        Evaluo si la carpeta especificada contiene archivos.
                    if (archivo != null) {
            //            Recorro el vector el cual tiene almacenado la ruta del archivo a buscar.
                        for (int i = 0; i < archivo.length; i++) {
                            File Arc = archivo[i];
            //                Evaluo si el archivo o la ruta es una carpeta.
                            if (archivo[i].isDirectory()) {
            //                    Le paso la nueva ruta de la carpeta si se cambia la ruta e busca nuevamente.
                                buscarArchivo(archivo[i]);
                            } else {
            //                    Evaluo el tipo de extencion. 
                                if (archivo[i].getName().endsWith(".pnd") || archivo[i].getName().endsWith(".ana") || archivo[i].getName().endsWith(".cnf")) {
                                    contador++;
                                    arrayArchivos.add(archivo[i].getName());
                                    System.out.println("Lo que hay en el array es: " + arrayArchivos);

                                    >>>Aquí necesitaría preguntar si existen archivos en el arraylist con las 3 extensiones que levanto de la carpeta.
                                    Los cuales son .pnd .ana .cnf<<<
                                }
                            }
                        }
                    }
                }
  • I need to know if there are 3 extensions inside the arraylist, regardless of the number of files it finds, if there are three extensions that do not do anything.
  • There may be up to 2 files with the same name but with different extension eg: ( juan.pnd and juan.ana ) or ( juan.pnd and juan.cnf ) in that case do nothing.
  • There may also be only two extensions, for example: pedro.cnf and pablo.ana
  • There can also be only 1 extension, for example: .ana alone or the .cnf alone.
  • The system should only do something if . . . . .pnd does not exist in the .pnd without the existence of the other two. In that case, only in that case that I trigger an arteta that what is in the arrayArchivos are only files with extension .pnd

I hope I have been clear about what I need, I would greatly appreciate your help, thank you very much.

    
asked by Gerardo Ferreyra 10.08.2017 в 20:12
source

1 answer

1

After about three months and finished my system and I managed to do what I was looking for in this question, this is the answer.

What I wanted to achieve was to remove the existing files from a specified folder and evaluate their extensions, for which use 3 arraylist, in one load all the files with the extensions I need ( .pnd ) , in another position the other files with other extensions ( .cnf .ana ) and in the third arraylist I only load the unique files without repeating their names with unique .pnd extensions, because within the specified folder you can see two or more files with the same name but with different extensions. If this condition is met, it would not add to the third arraylist, which would contain .pnd

answered by 17.09.2017 / 22:13
source