Logo

Programming-Idioms

  • Java
  • Python

Idiom #155 Delete file

Delete from filesystem the file having path filepath.

import os
os.remove(filepath)
import pathlib
path = pathlib.Path(_filepath)
path.unlink()
import static java.nio.file.Files.deleteIfExists;
import static java.nio.file.Path.of;
deleteIfExists(of(filepath));
import java.io.File;
new File(filepath).delete();
with Ada.Directories;
Ada.Directories.Delete_File (filepath);

New implementation...
< >
programming-idioms.org