diff options
Diffstat (limited to 'src/main/java/soundchan/LocalAudioManager.java')
-rw-r--r-- | src/main/java/soundchan/LocalAudioManager.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java index 4db7010..b34c8f4 100644 --- a/src/main/java/soundchan/LocalAudioManager.java +++ b/src/main/java/soundchan/LocalAudioManager.java @@ -112,14 +112,15 @@ public class LocalAudioManager { */ private Map<String, String> PopulateFiles(){ File folder = new File(filepath); - File[] listOfFiles = folder.listFiles(); - Map<String, String> fileDict = new HashMap<>(); + if(folder.exists() && folder.isDirectory()) { + File[] listOfFiles = folder.listFiles(); - for (File file : listOfFiles) { - if (file.isFile()) { - String filename = file.getName(); - fileDict.put(filename.substring(0, filename.indexOf('.')), filename); + for (File file : listOfFiles) { + if (file.isFile()) { + String filename = file.getName(); + fileDict.put(filename.substring(0, filename.indexOf('.')), filename); + } } } return fileDict; |