How to copy files from a specified text file in Java?

I’ve been stuck here for countless hours. I have a text file located in the destination directory that contains a list of files delineated by a line separator.
Such as:


The file is generated from this function (there are unnecessary elements as I’ve been manipulating for a while):

    void transferFiles(ActionEvent event) throws IOException {
        String source = donorPath.getText();
        String dest = recipientPath.getText();
        File dir = new File (source);
        String[] extensions = new String [] {"avi", "mpg"};
        List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
        String[] arr = new String[files.size()];
        String filename = "Before Transfer Copy.txt";
        String absolutePath;
        absolutePath = recipientPath + File.separator + filename;
        File fileT = new File(absolutePath);
        Path path = Path.of(dest);

        try (FileWriter fileWriter = new FileWriter(new File(dest, "Before Transfer Copy.txt"))) {
            for (File file : files) {
                fileWriter.write(file + System.getProperty("line.separator"));
        } catch (NullPointerException e) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("System Error");
            alert.setContentText("Files did not get copied");

and attempted to be copied from this one

    void copyFiles(ActionEvent event) throws IOException {
        String source = donorPath.getText();
        String dest = recipientPath.getText();
        Path path = Path.of(dest);
        AtomicReference<Path> p1 = new AtomicReference<>(Path.of(dest));

        String namingProblem = path.toString() + "Before Transfer Copy.txt";

        if (namingProblem.endsWith(".txt")) {
            System.out.println(namingProblem + " n You're inside the naming problem.");
            List<String> movingList = Files.readAllLines(Paths.get(namingProblem), StandardCharsets.UTF_8);
            System.out.println(movingList + "I'm the moving List");

            File activeD = new File(source);
            String[] fList = activeD.list();

            for(String loopInFileNames : movingList) {
                for (String file : fList) {
                    Files.copy(file.toPath(), (new File(String.valueOf(path))))


React markdown editor with preview

South Indian Bank Recruitment 2022 For Clerk, PO and Lateral PO Posts