From 7f0976b74dff706d223c96b40fb350f09bbc2c7f Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Thu, 19 Jul 2018 21:01:40 -0400 Subject: Adding checks that usersound file exists --- src/main/java/soundchan/LocalAudioManager.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/soundchan/LocalAudioManager.java') diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java index 80e3790..4b16850 100644 --- a/src/main/java/soundchan/LocalAudioManager.java +++ b/src/main/java/soundchan/LocalAudioManager.java @@ -122,19 +122,23 @@ public class LocalAudioManager { private static Properties LoadProperties(String filename){ Properties properties = new Properties(); InputStream input = null; - try{ - input = new FileInputStream(filename); - properties.load(input); - - }catch (IOException ex){ - ex.printStackTrace(); - } finally { + File file = new File(filename); + if(file.exists() && !file.isDirectory()) { try { - input.close(); + input = new FileInputStream(filename); + properties.load(input); } catch (IOException ex) { ex.printStackTrace(); + } finally { + try { + input.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } } + return properties; + } else { + return properties; } - return properties; } } -- cgit v1.2.3