Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int getMeTheResponseCodeOfURL(final URL url) {
- HttpURLConnection httpUrlConnection = null;
- int statusCode = 0;
- String userName = "ABCD\michael";
- String userPass = "password!6789";
- String UserAndPass = userName + ":" + userPass;
- String userPassBase64 = Base64.getEncoder().encodeToString(UserAndPass.getBytes());
- try {
- httpUrlConnection = (HttpURLConnection) url.openConnection();
- httpUrlConnection.setRequestProperty("Authorization", "Basic " + userPassBase64);
- httpUrlConnection.connect();
- statusCode = httpUrlConnection.getResponseCode();
- } catch (final IOException e) {
- this.log.error("IO Exception! Errormessage: " + e);
- }
- return statusCode;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement