What does the arrow operator, ‘->’, do in Java?

That’s part of the syntax of the new lambda expressions, to be introduced in Java 8. There are a couple of online tutorials to get the hang of it, here’s a link to one. Basically, the -> separates the parameters (left-side) from the implementation (right side). The general syntax for using lambda expressions is (Parameters) … Read more

Http Basic Authentication in Java using HttpClient?

Have you tried this (using HttpClient version 4): String encoding = Base64.getEncoder().encodeToString((user + “:” + pwd).getBytes()); HttpPost httpPost = new HttpPost(“http://host:post/test/login”); httpPost.setHeader(HttpHeaders.AUTHORIZATION, “Basic ” + encoding); System.out.println(“executing request ” + httpPost.getRequestLine()); HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity();