Advertisement
mikhail_dvorkin

Internet

Mar 15th, 2017
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.net.*;
  4.  
  5. public class Internet {
  6.     public static void main(final String[] args) throws Exception {
  7.         Proxy proxy = new Proxy(Proxy.Type.HTTP,
  8.                 new InetSocketAddress("192.168.0.2", 3128)
  9.                 );
  10. //      URL url = new URL("http://school.ioffe.ru/");
  11.         URL url = new URL("https://vk.com/api.php?lang=en&oauth=1&method=users.get&user_ids=7373");
  12.         HttpURLConnection connection = (HttpURLConnection)
  13.                 url.openConnection(proxy /* Only from school, otherwise no parameter here */);
  14.         BufferedReader br = new BufferedReader(
  15.                 new InputStreamReader(
  16.                         connection.getInputStream()/*, "KOI8-R"*/));
  17.         String s;
  18.         while ((s = br.readLine()) != null) {
  19.             System.out.println(s);
  20.         }
  21.         br.close();
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement