From 3863ece156ff79f001d46aa0dcda9f25cd61a733 Mon Sep 17 00:00:00 2001 From: Luca Longinotti Date: Thu, 7 Dec 2017 12:01:08 +0100 Subject: [PATCH] PlayWavFile: check for null InputStream before creating the buffered version. Fixes Eclipse cannot be null warning. --- src/net/sf/jaer/util/PlayWavFile.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net/sf/jaer/util/PlayWavFile.java b/src/net/sf/jaer/util/PlayWavFile.java index 3b03d8ec3..e0f25f9a3 100644 --- a/src/net/sf/jaer/util/PlayWavFile.java +++ b/src/net/sf/jaer/util/PlayWavFile.java @@ -79,18 +79,20 @@ public PlayWavFile(String wavfile, Position p) { /** * This method plays the file. Start the thread to play. */ - public void run() { + @Override + public void run() { BufferedInputStream is = null; - File soundFile = new File(filename); try { - is = new BufferedInputStream(new FileInputStream(soundFile)); + is = new BufferedInputStream(new FileInputStream(new File(filename))); } catch (FileNotFoundException e) { - is = new BufferedInputStream(getClass().getResourceAsStream(filename)); - if (is == null) { + final InputStream s = getClass().getResourceAsStream(filename); + if (s == null) { log.warning("Wave file not found on filesystem or classpath: " + filename); return; } + + is = new BufferedInputStream(s); } AudioInputStream audioInputStream = null;