diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-07 11:37:52 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-07 11:37:52 +0200 |
commit | eb278af8186496a6517bb1d27b7210bd173841fd (patch) | |
tree | a7c86070135f1653b8b37bf6b2d5c79b196bc301 /src | |
parent | 10206992c4d279c6460c1c44127f9450662cc05c (diff) | |
download | TwitterDataAnalytics-eb278af8186496a6517bb1d27b7210bd173841fd.tar.gz |
Shutdown hook for safely closing files
Diffstat (limited to 'src')
-rw-r--r-- | src/main/TweetShell.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/TweetShell.java b/src/main/TweetShell.java index 4ba50f3..231007f 100644 --- a/src/main/TweetShell.java +++ b/src/main/TweetShell.java @@ -49,6 +49,14 @@ public class TweetShell implements TwitterApi.PinSupplier { // and something that prints tweets to console. resultListeners.register(new StreamHandler()); // see getPossibleTargets() for more listener types. + + // register shutdown listener to prevent corruption on SIGINT + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + @Override + public void run() { + safeClose(); + } + })); } private TwitterApi getApi() throws IOException { |