code: public static boolean deleteOrDie(@Nonnull final String file) throws IOException {
          // this returns true if the file was actually deleted
          // and false for 2 cases:
          //   1. file did not exist to start with
          //   2. File.delete() failed at some point for some reason
          // so we disambiguate the 'false' case below by checking for file existence
          final boolean fileWasDeleted = delete(file);
  
          if (fileWasDeleted) {
              // file was definitely deleted
              return true;
          } else {
              final File fileObj = new File(file);
              if (fileObj.exists()) {
                  throw new IOException("File still exists after erasure, cannot write object to file: " + file);
              }
  
              // file was not deleted, because it does not exist
              return false;
          }
      }
docs: Deletes file or recursively deletes a directory
  @param file path to erase
  @return true if all deletions were successful, false if file did not exist
  @throws IOException if deletion fails and the file still exists at the end