Here you can find the source of deleteOnExit(Path path)
Parameter | Description |
---|---|
path | path to delete |
public static void deleteOnExit(Path path)
//package com.java2s; /*// w ww . j a v a 2 s.c om * Geotoolkit.org - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008-2012, Open Source Geospatial Foundation (OSGeo) * (C) 2009-2012, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.nio.file.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class Main { /** * Keep all {@link Path} to delete on JVM shutdown event on a concurrent Set. */ private static final Set<Path> DELETE_ON_EXIT_PATHS = Collections .newSetFromMap(new ConcurrentHashMap<Path, Boolean>()); /** * Register {@link Path} for a delete on JM shutdown event. * Under the hood, this method register path to be delete using {@link Runtime#addShutdownHook(Thread)}. * * @param path path to delete */ public static void deleteOnExit(Path path) { DELETE_ON_EXIT_PATHS.add(path); } }