I have a program in Java where when copying a group of files, when copying them, I copy them in the following way, this is the code of the method where you copy them:
public static void copyFiles(String src, String dst)
{
int x = 0;
eFilex = new File(src);
listOfFiles = eFilex.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
fileName = listOfFiles[i].getName();//Aqui es donde obtiene el nombre
if (fileName.endsWith(".pdf") || fileName.endsWith(".PDF"))//Evalua que sea tipo PDF
{
try {
srcPth = Paths.get(src, fileName);
eNumber = getNumber(fileName);
fDirectory = NewFolderNumber(dst, eNumber);
dstPth = Paths.get(fDirectory, fileName);
eFilex = new File(fDirectory, fileName);
if(!eFilex.exists())
{
try
{
Files.copy(srcPth, dstPth, StandardCopyOption.COPY_ATTRIBUTES);
System.out.println("Archivo organizado");
x++;
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
else
{
System.out.println("Ya existe el archivo..");
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
}
System.out.println("Archivos copiados: " + x);
}
In the variables that the method receives, there are only two addresses that I have in a propertie. The problem is that when you copy them in the new folder, put the name with the extension, to be called "S00A-205420-0000", now it is called "S00A-205420-0000.pdf" What is causing that?