Here you can find the source of deleteOnExit(final File file)
public static void deleteOnExit(final File file)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/*from w ww .j av a 2 s . c o m*/ * Schedule a file to be deleted when JVM exits. * If file is directory delete it and all sub-directories. */ public static void deleteOnExit(final File file) { file.deleteOnExit(); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { deleteOnExit(child); } } } } }