Solved Scanning a folder

Discussion in 'Plugin Development' started by Konkz, Apr 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Konkz

    Because I think making another post would be silly, I will ask question here - how would I go about scanning the folder plugins/MyPlugin/ and for every file there adding its name to an arraylist.

    Eg: If in that folder I have
    Song1.nbs
    Song2.nbs

    then if I was to run that method that scans and adds then print my arraylist I'd get
    {Song1.nbs, Song2.nbs}

    Old question
    Hey,

    I tried to make a .nbs file play once a user logs onto the server using NoteBlockAPI.
    Seems easy, 5 lines of code. Right? Well, I am facing an error that once I start the
    server there is as ClassNotFoundException - the class being part of the API.

    So I was wondering, what is the other way to play .nbs files found in plugins folder? (/plugins/pluginname/Song.nbs).
     
  2. Offline

    Aqua

    Did you add the API to the plugins folder, and add 'depend: [NoteBlockAPI]' to your plugin.yml?
     
  3. Offline

    CrazyGuy3000

    why not Softdepend?
     
    Konkz likes this.
  4. Offline

    Konkz

    I cri, I forgot about the depend: [NoteBlockAPI] - really weird that it needs it.

    EDIT:
    Because I think making another post would be silly, I will ask question here - how would I go about scanning the folder plugins/MyPlugin/ and for every file there adding its name to an arraylist.

    Eg: If in that folder I have
    Song1.nbs
    Song2.nbs

    then if I was to run that method that scans and adds then print my arraylist I'd get
    {Song1.nbs, Song2.nbs}

    Aqua CrazyGuy3000
     
  5. Offline

    CrazyGuy3000

    Use a for?
     
  6. Offline

    Konkz

    I am aware I have to loop but I am not exactly sure what to actually put inside it and such.
     
  7. Offline

    CrazyGuy3000

    Try creating a hashmap and then having a StringBuilder to show all the files.. perhaps?
     
  8. Offline

    ZeusAllMighty11

    Code:
    File directory = new File(getDataFolder(), "");
     
    for(File f  : directory.listFiles())
    {
        // each f.getName() ...
    }
    [/CODE\
     
  9. Offline

    Konkz

    Thanks, got it now! :)
     
Thread Status:
Not open for further replies.

Share This Page