簡體   English   中英

java applet-關閉applet或stop()時刪除(“ java.io.tmpdir”)+“ myfolder”內容

[英]java applet - delete (“java.io.tmpdir”)+“myfolder” contents on closing applet or stop()

我試圖清除我在java.io.tmpdir中編寫的myfolder內容(具有一些jar),以臨時使用applet。 現在,當我嘗試使用以下代碼刪除void stop()方法上的內容(罐子)時:

 public void stop()
{
 File directory = new File (System.getProperty("java.io.tmpdir")+"JarClassLoader");
                 // Get all files in directory
                    File[] files = directory.listFiles();
                    for (File file : files)
                    {

                        // Delete each file
                        if (!file.delete())
                        {   
                            // Failed to delete file
                    }
                }
}

它沒有清除任何內容,或者操作系統正在保存這些jar。 每次我運行一個applet時,這些jar都會不斷增加。是否有任何方法可以在applet stop上刪除這些內容?

File directory = new File (System.getProperty("java.io.tmpdir")+"JarClassLoader");

應該是:

File directory = new File (System.getProperty("java.io.tmpdir"), "JarClassLoader");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM