Facebook API を使用してユーザーの「興味」を読み取っています。
次のコードを使用して URL を読み取ろうとすると、java.net.sockettimeoutexception が発生します。
public static String readURL(URL url) throws IOException{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
URLConnection con = url.openConnection();
con.setConnectTimeout(20000);
con.setReadTimeout(20000);
InputStream is = con.getInputStream();
int r;
while ((r = is.read()) != -1) {
baos.write(r);
}
return new String(baos.toByteArray());
}
どうすればこれを処理できますか?私は何をすべきか?