Code example for URLConnection

Methods: getInputStream, setConnectTimeout, setReadTimeout, setRequestProperty

0
	private static Reader getReaderFromURL(String target) throws Exception {
		URL url = new URL(target);
 
		URLConnection urlConnection = url.openConnection();
		int time = 2000; // time logic is weird, I know, but it works
		urlConnection.setConnectTimeout(time);
		urlConnection.setReadTimeout(time * 2);
 
		urlConnection.setRequestProperty("Accept", "application/json");
 
		new Thread(new InterruptThread(Thread.currentThread(), urlConnection,
				time * (3 / 2))).start();
 
		InputStream input = urlConnection.getInputStream();
 
		Reader reader = new InputStreamReader(input, "UTF-8");
		return reader;
	} 
 
	/** For Gson parsing */ 
	private class PredictionResultGSON {