Code example for HttpURLConnection

Methods: addRequestProperty, getInputStream

0
		Config config = new Config();
 
		try { 
			URL url = new URL("http://gpodder.net/clientconfig.json");
			HttpURLConnection conn = (HttpURLConnection)url.openConnection();
			conn.addRequestProperty("User-Agent", "gpodder_provider/1.4");
			JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()));
			reader.beginObject();
			 
			// get mygpo 
			reader.nextName(); // should be mygpo
			reader.beginObject();
			reader.nextName(); // should be baseurl
			config.mygpo = reader.nextString();
			reader.endObject();
 
			// get mygpo-feedservice 
			reader.nextName(); // should be mygpo-feedservice
			reader.beginObject();
			reader.nextName(); // should be baseurl
			config.mygpo_feedservice = reader.nextString();