summaryrefslogtreecommitdiff
path: root/src/io/DataWriter.java
diff options
context:
space:
mode:
authorMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-01 17:09:31 +0200
committerMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-01 17:09:31 +0200
commit355bb332328a16ae967cf276bfdbe4cda0776c47 (patch)
treed6ba7b3cdcda3ae8da8ce6eff167f5c1395fcf58 /src/io/DataWriter.java
parent24fc22336273e919517cde2e8a81b5e4222f9e91 (diff)
downloadTwitterDataAnalytics-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/DataWriter.java')
-rw-r--r--src/io/DataWriter.java19
1 files changed, 15 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) {