diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-01 17:09:31 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-01 17:09:31 +0200 |
commit | 355bb332328a16ae967cf276bfdbe4cda0776c47 (patch) | |
tree | d6ba7b3cdcda3ae8da8ce6eff167f5c1395fcf58 /src/io | |
parent | 24fc22336273e919517cde2e8a81b5e4222f9e91 (diff) | |
download | TwitterDataAnalytics-355bb332328a16ae967cf276bfdbe4cda0776c47.tar.gz |
Added the target command with options: file, shell.
* Implemented target file, which uses DataWriter as
RequestListener which writes the tweets and profiles.
* Added profiles-filename, tweets-filename to the config.
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/DataWriter.java | 19 | ||||
-rw-r--r-- | src/io/StreamImpl.java | 4 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/io/DataWriter.java b/src/io/DataWriter.java index bbf0918..c26dbf3 100644 --- a/src/io/DataWriter.java +++ b/src/io/DataWriter.java @@ -39,14 +39,16 @@ public class DataWriter implements ResultListener { * the buffer of profile ids that already exist. */ private final Set<Long> m_profileIdSet; - - private static final String profilesName = "profiles.txt"; - private static final String tweetsName = "tweets.txt"; + + public final static String CFG_PROFILE_FILENAME = "profiles-filename"; + public final static String CFG_TWEETS_FILENAME = "tweets-filename"; /** * Opens a stream to every single file that data will be streamed to. + * @param profilesName The file to write the profiles to. + * @param tweetsName The file to write the tweets to. */ - public DataWriter() { + public DataWriter(final String profilesName, final String tweetsName) { try { m_profileIdSet = readIds(profilesName); m_profileWriter = new FileWriter(profilesName, true); @@ -58,6 +60,15 @@ public class DataWriter implements ResultListener { throw new RuntimeException(ex.getMessage()); } } + + public void close() { + try { + m_tweetWriter.close(); + m_profileWriter.close(); + } catch (IOException ex) { + getLogger().log(Level.SEVERE, null, ex); + } + } @Override public void profileGenerated(JSONObject obj) { diff --git a/src/io/StreamImpl.java b/src/io/StreamImpl.java index d72f926..16d0f2b 100644 --- a/src/io/StreamImpl.java +++ b/src/io/StreamImpl.java @@ -70,6 +70,10 @@ public class StreamImpl implements Stream { this.resultListener = resultListener; } + public ResultListener getResultListener() { + return resultListener; + } + public void setExceptionListener(ExceptionListener exceptionListener) { synchronized (listenerSync) { this.exceptionListener = exceptionListener; |