Guest User

Untitled

a guest
May 1st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Properties systemSettings = System.getProperties();
  2. String User = "myusername";
  3. String Password = "mypassword";
  4. systemSettings.put("proxySet", "true");
  5. systemSettings.put("https.proxyHost", "192.1.1.20");
  6. systemSettings.put("https.proxyPort", "8888");
  7. systemSettings.put("http.proxyHost", "192.1.1.20");
  8. systemSettings.put("http.proxyPort", "8888");
  9. Authenticator.setDefault(new ProxyAuthenticator(User ,Password));
  10.  
  11. HttpURLConnection conn = (HttpURLConnection) new URL("http://www.google.com/").openConnection();
  12. String encodedUserPwd = Base64Converter.encode("myuser:mypassword".getBytes());
  13.  
  14. conn.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd);
  15.  
  16. conn.connect();
  17.  
  18.  
  19. BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  20.  
  21. String inputLine;
  22. while ((inputLine = in.readLine()) != null) {
  23. }
  24.  
  25. WebView webView = new WebView();
  26. WebEngine engine = webView.getEngine();
  27. engine.load("http://www.google.com/");
  28.  
  29. VBox root = new VBox();
  30. root.getChildren().addAll(webView);
  31. Scene scene = new Scene(root, 1200, 700);
  32.  
  33. primaryStage.setScene(scene);
  34. primaryStage.show();
  35. in.close();
Add Comment
Please, Sign In to add comment