andgau

Conexiones

Feb 15th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. package es.sinjava.labs;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5. import java.net.URL;
  6. import java.net.URLConnection;
  7.  
  8. /**
  9.  * Hello world!
  10.  *
  11.  */
  12. public class App {
  13.     public static void main(String[] args) {
  14.         System.out.println("Hola Marinero");
  15.         String myURL = "http://sinjava.blogspot.com";
  16.         URL myUrl =null ;
  17.         try {
  18.             myUrl = new URL(myURL);
  19.             URLConnection connection = myUrl.openConnection();
  20.             BufferedReader input = new BufferedReader(new InputStreamReader(
  21.                     connection.getInputStream()));
  22.             StringBuilder sb = new StringBuilder();
  23.             String line;
  24.             while ((line = input.readLine()) != null)
  25.                 sb.append(line);
  26.             input.close();
  27.             System.out.println(sb.toString());
  28.         } catch (Exception e) {
  29.             System.out.println(e.getMessage());
  30.         }
  31.        
  32.         System.out.println("____ Ahora por protocolo seguro________");     
  33.    
  34.         myURL="https://preservicios3.aragon.es/scde_priv/login_goToLogin.action";
  35.         try {
  36.             myUrl = new URL(myURL);
  37.             URLConnection connection = myUrl.openConnection();
  38.             BufferedReader input = new BufferedReader(new InputStreamReader(
  39.                     connection.getInputStream()));
  40.             StringBuilder sb = new StringBuilder();
  41.             String line;
  42.             while ((line = input.readLine()) != null)
  43.                 sb.append(line);
  44.             input.close();
  45.             System.out.println(sb.toString());
  46.         } catch (Exception e) {
  47.             System.out.println(e.getMessage());
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment