Load xml from uri

public void load_xml_from_uri(String url) { try { URL direccion_xml = new URL(url); HttpURLConnection conection = (HttpURLConnection) direccion_xml.openConnection(); conection.connect(); InputStream stream = conection.getInputStream(); BufferedReader streamReader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); StringBuilder respondeStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) { respondeStrBuilder.append(inputStr); System.out.println(inputStr); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.