Infinite Loop in java

0

This code of my code is intended to rename a mass of files to set the following pattern: All compound names, the words should start in uppercase. First I give a substring for names that only have one word and then I make a while for compound names but it does not come out of while , can someone help me understand why? I'm trying to rename many files.

import java.io.File;

public class App {

    public static void main(String[] args) {
        File diretorio = new File("/home/douglas/roms");
        File[] arquivos = diretorio.listFiles();

        for (File arquivo : arquivos) {
            String nome;
            String extencao = ".gba";
            nome = arquivo.getName();
            nome = nome.toLowerCase();
            nome = nome.substring(0, nome.indexOf(extencao));
            nome = cortarTrecho(nome, " # gba");
            String primeira = nome.substring(0, 1).toUpperCase();
            String restante = nome.substring(1);
            nome = primeira + restante;

            while (nome.contains(" ")) {

                String nomeFinal = "";
                String partes[] = nome.split("\s+");

                for (int i = 0; i < partes.length; i++) {
                    nomeFinal += "*" + partes[i].substring(0, 1).toUpperCase() + partes[i].substring(1).toLowerCase();
                }
                nomeFinal = nomeFinal.substring(1) + extencao;
                System.out.println(nomeFinal);
            }

        }

    }

    public static String cortarTrecho(String nome, String trecho) {

        int index = nome.indexOf(trecho);
        nome = nome.substring(0, index);
        return nome;

    }

}
    
asked by anonymous 05.11.2016 / 12:55

1 answer

1

It was simple, just assigning the EndNode name value.

nome = nomeFinal;
    
05.11.2016 / 13:04