develog

AsyncHttpClient 본문

Dev/Java

AsyncHttpClient

냐옴 2013. 7. 11. 17:52

import java.util.concurrent.Future;


import com.ning.http.client.AsyncHttpClient;

import com.ning.http.client.AsyncHttpClientConfig;

import com.ning.http.client.Response;


public String send(String url) {

    try {

        AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder().setRequestTimeoutInMs(1 * 1000).build();

        AsyncHttpClient async = new AsyncHttpClient(config);

        Future<Response> future = async.prepareGet(url).execute();

        Response response = future.get();

        return = response.getResponseBody();

    } catch (Exception e) {

        return = "";

    }

}

'Dev > Java' 카테고리의 다른 글

jndi  (0) 2013.07.18
template, callback  (0) 2013.07.17
StringBuilder, replace  (0) 2013.07.11
spring-test-dbunit  (0) 2013.07.09
dbunit jar download  (0) 2013.07.09
Comments