summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-05-07 10:33:31 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-05-07 10:33:31 +0200
commit0fbe4a076ea1aa342fd4bdc23e10107c3e9aaa0c (patch)
tree45f2ce69205d29b8aaa29107917237399431f0e3
parent93aea47e3094302a27e01259348e52e3c9d3d0e2 (diff)
downloadTwitterDataAnalytics-0fbe4a076ea1aa342fd4bdc23e10107c3e9aaa0c.tar.gz
Use IOUtils.closeQuietly for less verbosity
-rw-r--r--src/io/StreamImpl.java16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/io/StreamImpl.java b/src/io/StreamImpl.java
index 3e432bf..4b3dd14 100644
--- a/src/io/StreamImpl.java
+++ b/src/io/StreamImpl.java
@@ -16,6 +16,7 @@ import java.util.logging.Logger;
import mining.Stream;
import oauth.signpost.exception.OAuthException;
import org.apache.commons.io.Charsets;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
@@ -259,12 +260,7 @@ public class StreamImpl implements Stream {
this.connection = connect(keywords);
this.inputStream = this.connection.getInputStream();
} catch (IOException ex) {
- if (this.inputStream != null) {
- try {
- this.inputStream.close();
- } catch (IOException ioex) {
- }
- }
+ IOUtils.closeQuietly(this.inputStream);
if (this.connection != null) {
this.connection.disconnect();
}
@@ -330,13 +326,7 @@ public class StreamImpl implements Stream {
} catch (IOException ex) {
run_error = ex;
} finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioex) {
- /* probably already closed? */
- }
- }
+ IOUtils.closeQuietly(is);
connection.disconnect();
if (run_error != null) {
// synchronize just in case the exception listener gets