I have a simple method for retrieving raw HTML from internet URL, but every time i run it, i am getting java.net.SocketTimeoutException
:
public static String getURL(String f) throws Exception{
String k="", result="";
URL url = new URL(f);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(10000);
conn.setRequestMethod("GET");
conn.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((k = rd.readLine()) != null) {
result += k + "\n";
}
conn.disconnect();
return result;
}
This same code was working fine long time ago, i just copy pasted to reuse this method, but seems like something has changed over the time or may be there is something else.
I have double checked Java/Javaw are allowed in firewall exceptions but strange thing, all app's when try to get internet access, i get a prompt in my firewall, but with this there is nothing happening. Seems like program never trys to actually send a request while it timesout in the method.
Can someone suggest what could be the problem>?