Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.net.URL;
  6.  
  7. /**
  8.  * Created by Tyler on 11/21/2014.
  9.  */
  10. public class ProxyTest {
  11.  
  12.     public void connect() throws IOException {
  13.  
  14.         System.setProperty("https.proxyHost", "184.107.204.83");
  15.         System.setProperty("https.proxyPort", "3128");
  16.  
  17.         URL url = new URL("http://whatsmyip.org/");
  18.         InputStream in = url.openStream();
  19.         BufferedReader br = new BufferedReader(new InputStreamReader(in));
  20.         String line = null;
  21.         while ((line = br.readLine()) != null ) {
  22.             System.out.println(line);
  23.         }
  24. //        System.setProperty("https.proxyHost", null);
  25.     }
  26.  
  27.     public static void main(String[] args) {
  28.         try {
  29.             new ProxyTest().connect();
  30.         } catch (IOException e) {
  31.             e.printStackTrace();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement