Completely Random Question

Discussion in 'Plugin Development' started by ludo0777, Mar 21, 2012.

Thread Status:
Not open for further replies.
  1. How do I get my plugin to find all files, in the same locations as it, with the same data as a variable and delete them?
     
  2. Offline

    Nitnelave

    What? What do you mean by a file "with the same data as a variable"? you mean the file is named like the variable? or in the contents there is the content of the variable? What does your variable hold? is it a String?
    You have to give us more info on that.
     
  3. I mean find all files where their content is the same as a string etc and delete them.
     
  4. Offline

    comp8nerd4u2

    You mean files with entirely duplicate contents or just duplicate content of just one String (Ex.: a player name maybe?)?
     
  5. Files with entirely duplicate contents.
     
  6. Offline

    Sorroko

    You would have to know the names of the files that could be created. The search through them and check for duplicate content.
     
  7. If you don't know the names of the files you can just point a File() to the directory and loop through them...
    Here's a example:
    Code:
    File dir = new File("relative/directory"); // if it's in your plugin folder, use getDataFolder(), don't hardcode it !
    
    for(File file : dir.listFiles())
    {
        if(file.isDirectory())
        {
             // you can choose to search deeper in folders
        }
        else
        {
             // check your file
        }
    }
    For deleting, you can find it yourself by typing file. and press ctrl+space to list methods. (on eclipse, I dunno for other IDEs)
     
Thread Status:
Not open for further replies.

Share This Page