Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In this </p> <pre><code>index.delete(); if (!index.exists()) { index.mkdir(); } </code></pre> <p>you are calling</p> <pre><code> if (!index.exists()) { index.mkdir(); } </code></pre> <p>after</p> <pre><code>index.delete(); </code></pre> <p>This means that you are creating the file again after deleting <a href="http://docs.oracle.com/javase/6/docs/api/java/io/File.html#delete%28%29" rel="nofollow noreferrer">File.delete()</a> returns a boolean value.So if you want to check then do <code>System.out.println(index.delete());</code> if you get <code>true</code> then this means that file is deleted</p> <pre><code>File index = new File("/home/Work/Indexer1");     if (!index.exists())        {              index.mkdir();        }     else{             System.out.println(index.delete());//If you get true then file is deleted             if (!index.exists())                {                    index.mkdir();// here you are creating again after deleting the file                }         } </code></pre> <p>from the <a href="https://stackoverflow.com/questions/20281835/how-to-delete-a-folder-with-files-using-java/20281925?noredirect=1#comment30258407_20281925">comments</a> given below,the updated answer is like this</p> <pre><code>File f=new File("full_path");//full path like c:/home/ri if(f.exists()) { f.delete(); } else { try { //f.createNewFile();//this will create a file f.mkdir();//this create a folder } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload