1
I’m having trouble understanding what the method really is .renameTo(); does.
Follow the example:
File arquivo = new File("caminho/nomeAtual.txt");
System.out.println(arquivo.getName());
arquivo.renameTo(new File("caminho/novoNome.txt"));
System.out.println(arquivo.getName());
Why do I need to put the new? The method creates a copy of the file contents and overwrites it?
I’m not sure, but the need to need two
Filemust have to do with therenameTo(). According to the documentation, this renaming operation may not be successful for a variety of reasons, so the use of a single objectFileis not enough to handle the situation.– Piovezan