Twitter выпустила клиентскую библиотеку Java и включал в себя следующий пример кода для его использования: объявлениеЧто это означает: MyClassName <String> в Java означает?
// Connect to the filter endpoint, tracking the term "twitterapi"
Hosts host = new BasicHost(Constants.STREAM_HOST);
StreamingEndpoint endpoint = new StatusesFilterEndpoint();
endpoint.trackTerms(Lists.newArrayList("twitterapi"));
// Drop in the oauth credentials for your app, available on dev.twitter.com
Authentication auth = new OAuth1("consumerKey", "consumerSecret",
"token", "tokenSecret");
// Initialize a queue to collect messages from the stream
BlockingQueue<String> messages = new LinkedBlockingQueue<String>(100000);
// Build a client and read messages until the connection closes.
ClientBuilder builder = new ClientBuilder()
.name("FooBarBaz-StreamingClient")
.hosts(host)
.authentication(auth)
.endpoint(endpoint)
.processor(new StringDelimitedProcessor(messages));
Client client = builder.build;
client.connect();
while (!client.isDone()) {
String message = messages.take();
// Do something with message
}
релиз по адресу: https://dev.twitter.com/blog/the-hosebird-client-streaming-library
Что угловые скобки означают?
Он указывает на [общий тип] (http://docs.oracle.com/javase/tutorial/java/generics/types.html), [Википедия] (http://en.wikipedia.org/wiki/ Generics_in_Java). – Lion