According to Android reference you can declare an URL using a string.
That means that the next code is supposed to be correct(i.e):
URL url = new URL("http://www.android.com/");
When I try to use it I get:
"java.net.MalformedURLException"
It happens to me on AndroidStudio 1.2.1.1
The full code I'm trying to use comes from the references of HttpURLConnect of Android:
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
readStream(in);
finally {
urlConnection.disconnect();
}
}