0

How to get the list of files in /tmp folder in Linux?

I tried with,

        File temp = File.createTempFile("temp.txt", ".tmp");
        temp.deleteOnExit();
        File[] tmpFiles = temp.listFiles();

But this doesn't work?

Basically I want to delete some files in /tmp directory of linux.

AJJ
  • 3,570
  • 7
  • 43
  • 76
  • 1
    You need to create a pointer to /tmp and then check it exists and finally iterate through the folder contents – David Brossard Jun 10 '16 at 11:25
  • You might want to read this doc: https://docs.oracle.com/javase/8/docs/api/java/io/File.html#createTempFile-java.lang.String-java.lang.String- –  Jun 10 '16 at 11:27

0 Answers0