Try this: URL url = new URL("some url"); //create the new connection HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection() ...
stackoverflow.com