关于Authenticator.setDefault使用问题 求帮忙 stringclassurlhtml 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看一下老外找到的变通方法,他说这是个 bug,不知道是不是真的:http://stackoverflow.com/questions/480895/reset-the-authenticator-credentials http://stackoverflow.com/questions/480895/reset-the-authenticator-credentials用这个里面的处理方法还是没有解决,唉 你试过在每个连接之前用这个 set MyCache() 么?这个 MyCache 实际上并不缓存,任何请求缓存的操作都被忽视。按这个人的经验,直接用 new AuthCacheImpl() 得到的依然不行,他是在 debug 时略有延迟的时候就正常,不是 debug 没有延迟立即完成的时候就不正常。https://community.oracle.com/thread/2152686?start=0&tstart=0static class MyCache implements sun.net.www.protocol.http.AuthCache{ public void put(String pkey, sun.net.www.protocol.http.AuthCacheValue value){ } public sun.net.www.protocol.http.AuthCacheValue get(String pkey, String skey){ return null; } public void remove(String pkey, sun.net.www.protocol.http.AuthCacheValue entry){ }}static{ sun.net.www.protocol.http.AuthCacheValue.setAuthCache(new MyCache());} 这个 bug 2007年就提交了,但显示的是没处理。可能的理解就是:使用它默认的就是这个结果,如果我们想要自己的,可以提供自己的 AuthCache 实现方法。 http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6626700 最终放弃了使用Authenticator.setDefault(new BasicAuthenticator(username,password));换成以下代码实现,可以了 String users = username+":"+password; httpsConn.addRequestProperty("Authorization", "Basic "+encode(users.getBytes()));再次感谢humanity 的帮忙,多谢 编译通过,运行报错,请高手指导,谢谢! try....catch...finally 急!SequenceInputStream读取时报“该流已关闭”,大家帮忙啊! >>>>>>>>关于抽象类<<<<<<<<<<<<< 跪求————关于字符串作为函数参数的一个简单问题,在线等!! 关于java程序与非java程序间拖放功能的问题。 这个怪事你们谁碰过? 请问vector的容量是否有限制? 如何去掉java源文件与文本编辑器的结合 困扰了我一天的难题,请指教!! 关于使用Java布局管理器在板面绘图的问题 java 多线程添加数据
http://stackoverflow.com/questions/480895/reset-the-authenticator-credentials
用这个里面的处理方法还是没有解决,唉
public void put(String pkey, sun.net.www.protocol.http.AuthCacheValue value){ }
public sun.net.www.protocol.http.AuthCacheValue get(String pkey, String skey){
return null;
}
public void remove(String pkey, sun.net.www.protocol.http.AuthCacheValue entry){ }
}
static{
sun.net.www.protocol.http.AuthCacheValue.setAuthCache(new MyCache());}
换成以下代码实现,可以了
String users = username+":"+password;
httpsConn.addRequestProperty("Authorization", "Basic "+encode(users.getBytes()));再次感谢humanity 的帮忙,多谢