Advertisement
Guest User

Test.java

a guest
May 6th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.net.Socket;
  4. import java.security.NoSuchAlgorithmException;
  5.  
  6. import javax.net.ssl.SSLContext;
  7. import javax.net.ssl.SSLEngine;
  8.  
  9. public class Test {
  10.  
  11.         public static void main(String[] args) throws NoSuchAlgorithmException, Exception {
  12.                 Socket s = SSLContext.getDefault().getSocketFactory().createSocket("google.com", 443);
  13.                 s.getOutputStream().write("GET / HTTP/1.0\r\n\r\n".getBytes());
  14.                 InputStream inputStream = s.getInputStream();
  15.                 int c;
  16.                 while ((c = inputStream.read()) > -1) {
  17.                     System.out.print((char)c);
  18.                 if (c<=13)
  19.                    break;
  20.             }
  21.       }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement