How to remane the temp file to original text file? : Hello my code basically **delete the empty lines from txt file**, but i want at the end temp file take the originals name.

        String inputFileName = "src/inware/users.txt";
        String outputFileName = "src/inware/usersT.txt";

        try (BufferedReader inputFile = new BufferedReader(new FileReader(inputFileName));
             PrintWriter outputFile = new PrintWriter(new FileWriter(outputFileName))) {
            String lineOfText;
            while ((lineOfText = inputFile.readLine()) != null) {
                lineOfText = lineOfText.trim();
                if (!lineOfText.isEmpty()) {
                    outputFile.println(lineOfText);
                }
            }
            inputFile.close();
            outputFile.close();
          
        } catch (IOException ex) {
            Logger.getLogger(ManageStudentController.class.getName()).log(Level.SEVERE, null, ex);
        }

I try

            inputFile.delete();
            outputFile.renameTo(inputFile);

But is not working... Any solution??