你好,我在 StackOverflow 上看到了一个示例,其中包含以下代码:
String encoding = Base64Encoder.encode ("test1:test1");
HttpPost httppost = new HttpPost("http://host:post/test/login");
httppost.setHeader("Authorization", "Basic " + encoding);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
我有一个类似的任务。我尝试使用相同的代码,但是我无法找到任何Base64Encoder类。我正在使用httpclient-4.1.2.jar和httpcore-4.1.2.jar。有人能帮助我解决这个问题吗?