Example usage for twitter4j StatusListener StatusListener

List of usage examples for twitter4j StatusListener StatusListener

Introduction

In this page you can find the example usage for twitter4j StatusListener StatusListener.

Prototype

StatusListener

Source Link

Usage

From source file:adapter.TwitterAllAdapter.java

License:Apache License

public void connectAndRead() throws Exception {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    Properties twitterProperties = new Properties();
    /*File twitter4jPropsFile = new File(System.getProperty("user.home")
    + "/twitter4j.properties");*/
    File twitter4jPropsFile = new File("../twitter4j.properties");
    if (!twitter4jPropsFile.exists()) {
        logger.error("Cannot find twitter4j.properties file in this location :[{}]",
                twitter4jPropsFile.getAbsolutePath());
        return;/*from   ww  w .ja  v  a  2  s  .c  o  m*/
    }

    twitterProperties.load(new FileInputStream(twitter4jPropsFile));

    cb = new ConfigurationBuilder();

    cb.setOAuthConsumerKey(twitterProperties.getProperty("oauth.consumerKey"));
    cb.setOAuthConsumerSecret(twitterProperties.getProperty("oauth.consumerSecret"));
    cb.setOAuthAccessToken(twitterProperties.getProperty("oauth.accessToken"));
    cb.setOAuthAccessTokenSecret(twitterProperties.getProperty("oauth.accessTokenSecret"));

    cb.setDebugEnabled(false);
    cb.setPrettyDebugEnabled(false);
    cb.setIncludeMyRetweetEnabled(false);

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    StatusListener statusListener = new StatusListener() {

        @Override
        public void onException(Exception ex) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onStatus(Status status) {
            messageQueue.add(status);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

    };

    twitterStream.addListener(statusListener);
    twitterStream.sample();

}

From source file:adapter.TwitterKeywordsAdapter.java

License:Apache License

public void connectAndRead() throws Exception {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    Properties twitterProperties = new Properties();
    File twitter4jPropsFile = new File("../twitter4j.properties");
    if (!twitter4jPropsFile.exists()) {
        logger.error("Cannot find twitter4j.properties file in this location :[{}]",
                twitter4jPropsFile.getAbsolutePath());
        return;//from   w ww.  j a  v a 2 s. c o m
    }

    twitterProperties.load(new FileInputStream(twitter4jPropsFile));

    cb = new ConfigurationBuilder();

    cb.setOAuthConsumerKey(twitterProperties.getProperty("oauth.consumerKey"));
    cb.setOAuthConsumerSecret(twitterProperties.getProperty("oauth.consumerSecret"));
    cb.setOAuthAccessToken(twitterProperties.getProperty("oauth.accessToken"));
    cb.setOAuthAccessTokenSecret(twitterProperties.getProperty("oauth.accessTokenSecret"));

    cb.setDebugEnabled(false);
    cb.setPrettyDebugEnabled(false);
    cb.setIncludeMyRetweetEnabled(false);

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    StatusListener statusListener = new StatusListener() {
        @Override
        public void onException(Exception ex) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onStatus(Status status) {
            messageQueue.add(status);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

    };

    FilterQuery fq = new FilterQuery();

    //System.out.println(Arrays.toString(configuration.getTrack()));

    //Elige todos los tweets que posean esas palabras claves
    fq.track(new String[] { "palabra1,palabra2,palabra3" });
    //fq.track(keywords);
    twitterStream.addListener(statusListener);
    twitterStream.filter(fq);
}

From source file:adapter.TwitterLanguageAdapter.java

License:Apache License

public void connectAndRead() throws Exception {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    Properties twitterProperties = new Properties();
    File twitter4jPropsFile = new File("../twitter4j.properties");
    if (!twitter4jPropsFile.exists()) {
        logger.error("Cannot find twitter4j.properties file in this location :[{}]",
                twitter4jPropsFile.getAbsolutePath());
        return;//from www.jav a2  s  . c o m
    }

    twitterProperties.load(new FileInputStream(twitter4jPropsFile));

    cb = new ConfigurationBuilder();

    cb.setOAuthConsumerKey(twitterProperties.getProperty("oauth.consumerKey"));
    cb.setOAuthConsumerSecret(twitterProperties.getProperty("oauth.consumerSecret"));
    cb.setOAuthAccessToken(twitterProperties.getProperty("oauth.accessToken"));
    cb.setOAuthAccessTokenSecret(twitterProperties.getProperty("oauth.accessTokenSecret"));

    cb.setDebugEnabled(false);
    cb.setPrettyDebugEnabled(false);
    cb.setIncludeMyRetweetEnabled(false);

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    StatusListener statusListener = new StatusListener() {
        @Override
        public void onException(Exception ex) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onStatus(Status status) {
            messageQueue.add(status);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

    };

    //Filter language and track
    FilterQuery tweetFilterQuery = new FilterQuery();
    tweetFilterQuery.track(new String[] { "palabra1,palabra2,palabra3" });
    tweetFilterQuery.language(new String[] { "es" });

    //TwitterStream
    twitterStream.addListener(statusListener);
    twitterStream.filter(tweetFilterQuery);
}

From source file:adapter.TwitterLocationAdapter.java

License:Apache License

public void connectAndRead() throws Exception {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    Properties twitterProperties = new Properties();
    File twitter4jPropsFile = new File("../twitter4j.properties");
    if (!twitter4jPropsFile.exists()) {
        logger.error("Cannot find twitter4j.properties file in this location :[{}]",
                twitter4jPropsFile.getAbsolutePath());
        return;/*from  www .j  av  a  2 s  .  c  om*/
    }

    twitterProperties.load(new FileInputStream(twitter4jPropsFile));

    cb = new ConfigurationBuilder();

    cb.setOAuthConsumerKey(twitterProperties.getProperty("oauth.consumerKey"));
    cb.setOAuthConsumerSecret(twitterProperties.getProperty("oauth.consumerSecret"));
    cb.setOAuthAccessToken(twitterProperties.getProperty("oauth.accessToken"));
    cb.setOAuthAccessTokenSecret(twitterProperties.getProperty("oauth.accessTokenSecret"));

    cb.setDebugEnabled(false);
    cb.setPrettyDebugEnabled(false);
    cb.setIncludeMyRetweetEnabled(false);

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    StatusListener statusListener = new StatusListener() {
        @Override
        public void onException(Exception ex) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onStatus(Status status) {
            messageQueue.add(status);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

    };

    FilterQuery fq = new FilterQuery();
    // Posiciones geogrficas, esas dos coordenadas son el vrtice superior izquierda e inferior derecho
    // de un rectangulo, de tal manera de analizar solo una parte geografica
    double position[][] = { { 0.0, 0.0 }, { 0.0, 0.0 } };
    fq.locations(position);

    twitterStream.addListener(statusListener);
    twitterStream.filter(fq);
}

From source file:algo.ad.feeder.TwitterStreamSpout.java

License:Apache License

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    queue = new LinkedBlockingQueue<Status>(1000);
    _collector = collector;/*from  w w w.j  a v  a 2 s . c  om*/
    startTime = System.currentTimeMillis();
    StatusListener listener = new StatusListener() {

        @Override
        public void onStatus(Status status) {
            long elapsedTime = System.currentTimeMillis() - startTime;
            //System.out.println("*************elapsedTime:" + elapsedTime);
            if (elapsedTime > keywordRefreshInterval) {

                ///   System.out.println("*************Changing Query:");

                // Update the keyword list////////////////////
                String[] temp_keywords = DatabaseHelper.getKeywordsFromDB(tweetsJDBCTemplate, DB_BASE_URL,
                        DB_NAME, MAX_NUMBER_OF_QUERIES);
                if (!keyWords.equals(temp_keywords)) {
                    keyWords = temp_keywords;
                    FilterQuery query = new FilterQuery().track(keyWords);
                    _twitterStream.filter(query);
                }
                // /////////////////////////////////////
                startTime = System.currentTimeMillis();
            }
            queue.offer(status);
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice sdn) {
        }

        @Override
        public void onTrackLimitationNotice(int i) {
        }

        @Override
        public void onScrubGeo(long l, long l1) {
        }

        @Override
        public void onException(Exception ex) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
            // TODO Auto-generated method stub

        }

    };

    _twitterStream = new TwitterStreamFactory(new ConfigurationBuilder().setJSONStoreEnabled(true).build())
            .getInstance();

    _twitterStream.addListener(listener);
    _twitterStream.setOAuthConsumer(consumerKey, consumerSecret);
    AccessToken token = new AccessToken(accessToken, accessTokenSecret);
    _twitterStream.setOAuthAccessToken(token);

    keyWords = DatabaseHelper.getKeywordsFromDB(tweetsJDBCTemplate, DB_BASE_URL, DB_NAME,
            MAX_NUMBER_OF_QUERIES);

    if (keyWords.length == 0) {

        _twitterStream.sample();
    }

    else {

        FilterQuery query = new FilterQuery().track(keyWords);

        _twitterStream.filter(query);
    }

}

From source file:ar.com.zauber.commons.social.twitter.impl.streaming.TweetFetcher.java

License:Apache License

/**
 * Creates the {@link TwitterStream}//from   w  w  w.  j  a  va2s. c o m
 * 
 * @param user
 * @param password
 * @return
 */
private TwitterStream createStream(final String user, final String password) {
    final TwitterStream stream = new TwitterStreamFactory().getInstance(new BasicAuthorization(user, password));

    stream.addListener(new StatusListener() {
        @Override
        public void onStatus(final Status status) {
            try {
                T t = transformer.transform(status);
                closure.execute(t);
            } catch (Throwable ex) {
                logger.error("Exception en onStatus", ex);
            }

        }

        @Override
        public void onException(final Exception e) {
            logger.error("Exception on TwitterStream", e);
        }

        @Override
        public void onTrackLimitationNotice(final int numberOfLimitedStatuses) {
            logger.warn("onTrackLimitationNotice: Number of limited " + "statuses: {}",
                    numberOfLimitedStatuses);
        }

        @Override
        public void onDeletionNotice(final StatusDeletionNotice statusDeletionNotice) {
            logger.warn("statusDeletionNotice: {}", statusDeletionNotice);
        }

        @Override
        public void onScrubGeo(final long userId, final long upToStatusId) {
            logger.warn("scrubGeo: {} {}", userId, upToStatusId);
        }
    });

    stream.addConnectionLifeCycleListener(new ConnectionLifeCycleListener() {
        @Override
        public void onDisconnect() {
            logger.warn("Disconnected from Twitter!");
        }

        @Override
        public void onConnect() {
        }

        @Override
        public void onCleanUp() {
        }
    });

    return stream;
}

From source file:at.aictopic1.twitter.AICStream.java

private StatusListener getListener() {
    return new StatusListener() {
        public void onStatus(Status status) {
            String rawJSON = TwitterObjectFactory.getRawJSON(status);

            File file = new File(AICStream.filePath);

            BufferedWriter writer = null;
            try {
                writer = new BufferedWriter(new FileWriter(file, true));
                writer.append(rawJSON);//  w  w  w.j a v a 2 s.  co  m
                writer.newLine();
                writer.flush();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(AICStream.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AICStream.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                if (writer != null) {
                    try {
                        writer.close();
                    } catch (IOException ex) {
                        Logger.getLogger(AICStream.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }

        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
        }

        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
        }

        public void onException(Exception ex) {
            ex.printStackTrace();
        }

        public void onScrubGeo(long userId, long upToStatusId) {
            System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
        }

        public void onStallWarning(StallWarning warning) {
            System.out.println("Got stall warning:" + warning);
        }
    };
}

From source file:at.illecker.sentistorm.spout.TwitterStreamSpout.java

License:Apache License

@Override
public void open(Map config, TopologyContext context, SpoutOutputCollector collector) {
    m_collector = collector;//from  w ww. ja va  2 s . co m
    m_tweetsQueue = new LinkedBlockingQueue<Status>(1000);

    // Optional startup sleep to finish bolt preparation
    // before spout starts emitting
    if (config.get(CONF_STARTUP_SLEEP_MS) != null) {
        long startupSleepMillis = (Long) config.get(CONF_STARTUP_SLEEP_MS);
        TimeUtils.sleepMillis(startupSleepMillis);
    }

    TwitterStream twitterStream = new TwitterStreamFactory(
            new ConfigurationBuilder().setJSONStoreEnabled(true).build()).getInstance();

    // Set Listener
    twitterStream.addListener(new StatusListener() {
        @Override
        public void onStatus(Status status) {
            m_tweetsQueue.offer(status); // add tweet into queue
        }

        @Override
        public void onException(Exception arg0) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice arg0) {
        }

        @Override
        public void onScrubGeo(long arg0, long arg1) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

        @Override
        public void onTrackLimitationNotice(int arg0) {
        }
    });

    // Set credentials
    twitterStream.setOAuthConsumer(m_consumerKey, m_consumerSecret);
    AccessToken token = new AccessToken(m_accessToken, m_accessTokenSecret);
    twitterStream.setOAuthAccessToken(token);

    // Filter twitter stream
    FilterQuery tweetFilterQuery = new FilterQuery();
    if (m_keyWords != null) {
        tweetFilterQuery.track(m_keyWords);
    }

    // Filter location
    // https://dev.twitter.com/docs/streaming-apis/parameters#locations
    tweetFilterQuery.locations(new double[][] { new double[] { -180, -90, }, new double[] { 180, 90 } }); // any geotagged tweet

    // Filter language
    tweetFilterQuery.language(new String[] { m_filterLanguage });

    twitterStream.filter(tweetFilterQuery);
}

From source file:at.storm.spout.TwitterStreamSpout.java

License:Apache License

@SuppressWarnings("rawtypes")
@Override//from www.  j a v a2s .  com
public void open(Map config, TopologyContext context, SpoutOutputCollector collector) {
    m_collector = collector;
    m_tweetsQueue = new LinkedBlockingQueue<Status>(1000);

    // Optional startup sleep to finish bolt preparation
    // before spout starts emitting
    if (config.get(CONF_STARTUP_SLEEP_MS) != null) {
        long startupSleepMillis = (Long) config.get(CONF_STARTUP_SLEEP_MS);
        TimeUtils.sleepMillis(startupSleepMillis);
    }

    TwitterStream twitterStream = new TwitterStreamFactory(
            new ConfigurationBuilder().setJSONStoreEnabled(true).build()).getInstance();

    // Set Listener
    twitterStream.addListener(new StatusListener() {
        @Override
        public void onStatus(Status status) {
            m_tweetsQueue.offer(status); // add tweet into queue
        }

        @Override
        public void onException(Exception arg0) {
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice arg0) {
        }

        @Override
        public void onScrubGeo(long arg0, long arg1) {
        }

        @Override
        public void onStallWarning(StallWarning arg0) {
        }

        @Override
        public void onTrackLimitationNotice(int arg0) {
        }
    });

    // Set credentials
    twitterStream.setOAuthConsumer(m_consumerKey, m_consumerSecret);
    AccessToken token = new AccessToken(m_accessToken, m_accessTokenSecret);
    twitterStream.setOAuthAccessToken(token);

    // Filter twitter stream
    FilterQuery tweetFilterQuery = new FilterQuery();
    if (m_keyWords != null) {
        tweetFilterQuery.track(m_keyWords);
    }

    // Filter location
    // https://dev.twitter.com/docs/streaming-apis/parameters#locations
    tweetFilterQuery.locations(new double[][] { new double[] { -180, -90, }, new double[] { 180, 90 } }); // any
    // geotagged
    // tweet

    // Filter language
    tweetFilterQuery.language(new String[] { m_filterLanguage });

    twitterStream.filter(tweetFilterQuery);
}

From source file:bditac.TwitterCaptura.java

public static void main(String[] args) throws TwitterException {

    int criid, apiid, capid;

    if (args.length == 3) {
        criid = Integer.parseInt(args[0]);
        apiid = Integer.parseInt(args[1]);
        capid = Integer.parseInt(args[2]);
    } else {//from   www  .j a  v a2  s  .  co  m
        criid = 1;
        apiid = 1;
        capid = 1;
    }

    CriseJpaController crijpa = new CriseJpaController(factory);

    Crise crise = crijpa.findCrise(criid);

    CriseApiJpaController criapijpa = new CriseApiJpaController(factory);

    CriseApi criapi = criapijpa.findCriseApi(capid);

    ApiJpaController apijpa = new ApiJpaController(factory);

    Api api = apijpa.findApi(apiid);

    CidadeJpaController cidjpa = new CidadeJpaController(factory);

    Cidade cidade = cidjpa.findCidade(crise.getCidId());

    String coords[] = crise.getCriRegiao().split(",");

    TwitterGeo geo = new TwitterGeo(coords, cidade.getCidNome(), crise.getCriGeotipo());

    Thread threadGeo = new Thread(geo);

    TwitterMens mens = new TwitterMens(crise.getCrtId());

    Thread threadMens = new Thread(mens);

    TwitterGravar gravar = new TwitterGravar();

    Thread threadGravar = new Thread(gravar);

    threadGeo.setName("ThreadGeo");
    threadGeo.start();

    threadMens.setName("ThreadMens");
    threadMens.start();

    threadGravar.setName("ThreadGravar");
    threadGravar.start();

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(criapi.getCapKey())
            .setOAuthConsumerSecret(criapi.getCapSecret()).setOAuthAccessToken(criapi.getCapToken())
            .setOAuthAccessTokenSecret(criapi.getCapTokenSecret());

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    String texto = "[\\xF0\\x9F]";

    StatusListener listener;
    listener = new StatusListener() {
        int cont = 0;

        @Override
        public void onStatus(Status status) {
            if (!(status.getText().contains(texto) || status.getText().isEmpty())) {
                Ocorrencia ocor = new Ocorrencia();
                ocor.setApiId(apiid);
                ocor.setCriId(criid);
                ocor.setCapId(capid);

                ocor.setOcrIdApi(status.getId());
                ocor.setOcrCriacao(status.getCreatedAt());
                ocor.setOcrTexto(status.getText());
                //                    System.out.println(ocor.getOcrTexto());
                ocor.setOcrUsuId(status.getUser().getId());
                ocor.setOcrUsuNome(status.getUser().getName());
                ocor.setOcrUsuScreenNome(status.getUser().getScreenName());
                ocor.setOcrFonte(status.getSource());
                ocor.setOcrLingua(status.getLang());
                ocor.setOcrFavorite(status.getFavoriteCount());
                ocor.setOcrRetweet(status.getRetweetCount());
                String coords = "";
                if (status.getPlace() == null) {
                    ocor.setOcrPaisCodigo("");
                    ocor.setOcrPais("");
                    ocor.setOcrLocal("");
                } else {
                    ocor.setOcrPaisCodigo(status.getPlace().getCountryCode());
                    ocor.setOcrPais(status.getPlace().getCountry());
                    ocor.setOcrLocal(status.getPlace().getFullName());
                    GeoLocation locs[][] = status.getPlace().getBoundingBoxCoordinates();
                    for (int x = 0; x < locs.length; x++) {
                        for (int y = 0; y < locs[x].length; y++) {
                            coords += "[" + locs[x][y].getLongitude() + "," + locs[x][y].getLatitude() + "]";
                            if (!(x == locs.length - 1 && y == locs[x].length - 1)) {
                                coords += ",";
                            }
                        }
                    }
                }

                ocor.setOcrCoordenadas(coords);
                ocor.setOcrGeo('0');
                ocor.setOcrIdentificacao('0');
                ocor.setOcrIdenper(0.0f);
                ocor.setOcrGravado('0');
                ocor.setOcrSentimento('0');
                ocor.setOcrTempo('0');

                boolean add = ocors.add(ocor);

                cont++;

                if (ocors.size() > 1000) {
                    Limpar();
                }

                //                    System.out.println(cont+" - "+status.getId() + " - " + status.getCreatedAt() + status.getPlace().getFullName());
            }
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
        }

        @Override
        public void onScrubGeo(long userId, long upToStatusId) {
            System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
        }

        @Override
        public void onStallWarning(StallWarning warning) {
            System.out.println("Got stall warning:" + warning);
        }

        @Override
        public void onException(Exception ex) {
            ex.printStackTrace();
        }

        private void Limpar() {
            while (!threadGeo.isInterrupted()) {
                threadGeo.interrupt();
            }
            while (!threadMens.isInterrupted()) {
                threadMens.interrupt();
            }
            while (!threadGravar.isInterrupted()) {
                threadGravar.interrupt();
            }
            boolean achou = true;
            int x = 0;
            System.out.println("Removendo: " + ocors.size());
            while (x < ocors.size()) {
                if (ocors.get(x).getOcrGravado() != '0') {
                    ocors.remove(x);
                } else {
                    x++;
                }
            }
            System.out.println("Final: " + ocors.size());
            if (!threadGeo.isAlive()) {
                threadGeo.start();
            }
            if (!threadMens.isAlive()) {
                threadMens.start();
            }
            if (!threadGravar.isAlive()) {
                threadGravar.start();
            }
        }
    };

    FilterQuery filter = new FilterQuery();

    double[][] location = new double[2][2];

    location[0][0] = Double.parseDouble(coords[0]);
    location[0][1] = Double.parseDouble(coords[1]);
    location[1][0] = Double.parseDouble(coords[4]);
    location[1][1] = Double.parseDouble(coords[5]);

    filter.locations(location);

    twitterStream.addListener(listener);

    twitterStream.filter(filter);
}