Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.*;
- import java.nio.charset.Charset;
- public class HelloWorld {
- public static void main (String[] args) {
- URL url;
- HttpURLConnection connection;
- BufferedReader readingData;
- String requestSite = "http://www.cbr.ru/scripts/XML_daily.asp";
- String responseLine;
- String responseData = null;
- try {
- url = new URL(requestSite);
- connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- readingData = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- while ((responseLine = readingData.readLine()) != null) {
- responseData += responseLine;
- }
- readingData.close();
- System.out.println(responseData);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement