Delete a file with Files and Paths : Files « JDK 7 « Java

Delete a file with Files and Paths

import java.nio.file.Files;
import java.nio.file.Paths;

public class Test {

  public static void main(String[] args) throws Exception{
    Files.delete(Paths.get(new URI("file:///tmp.txt")));


Related examples in the same category

1.Create BufferReader from Files class
2.Create BufferedReader with default charset
3.Interoperability between and java.nio.file.Files
4.File Information
5.Filtering a directory using globbing
6.Get file last modified time for a path object by using Files class
7.Get the file size
8.Is file a symbolic link
9.Is a path a directory