title: How to delete .dat file in Java?
body: <p>I want to delete a .dat file. This is my code but it does not work.</p>
  
  <pre><code>String searchCust = SearchCust.getText();
  
      File file = new File(searchCust + " booking.dat");
      if (file.delete()) {
          JOptionPane.showMessageDialog(null, "Info deleted");
  
      } else {
          JOptionPane.showMessageDialog(null, "Delete failed");
      }
  </code></pre>
  
  <p>Basically when i run, the file is not deleted and the "Delete failed" message will appear</p>