OkHttp 用起來真的很方便。
官方網站:http://square.github.io/okhttp/
As of OkHttp3 can now do this through the Builder like so
client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
You can also view the recipe here