Code example for URI

Methods: toASCIIString

0
            return new Observation(); 
        } 
 
        String query = "w=" + woeid + "&u=c";
        try { 
            java.net.URI uri = new URI("http", "weather.yahooapis.com", "/forecastrss", query, null);
            URL url = new URL(uri.toASCIIString());
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            try { 
                if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    InputStream in = new BufferedInputStream(conn.getInputStream());
                    return readStream(in);
                } 
            } finally { 
                conn.disconnect();
            } 
        } catch (MalformedURLException e) {
            Log.wtf(TAG, "Invalid URL", e);
        } catch (IOException e) {
            Log.e(TAG, "Failed to retrieve weather data", e);
            return null;