罗马XmlReader不读取https feed - java

我正在尝试阅读https://d3ca01230439ce08d4aab0c61810af23:[email protected]/recordings.atom

使用罗马,但给我错误

   INFO: Illegal access: this web application instance has been stopped already.  Could not load org.bouncycastle.jcajce.provider.symmetric.AES$ECB.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.

   Server returned HTTP response code: 401 for URL: https://d3ca01230439ce08d4aab0c61810af23:[email protected]/recordings.atom .

我正在做这个

    URL url =  new URL("https://d3ca01230439ce08d4aab0c61810af23:[email protected]/recordings.atom ");

    try {
    SyndFeedInput input = new SyndFeedInput();

        SyndFeed feed = input.build(new XmlReader(url));

        System.out.println("Feed Author:"+feed.getAuthor());

        for(Object entries: feed.getEntries()){

            SyndEntry entry = (SyndEntry) entries;

            System.out.println("title :"+entry.getTitle());
            System.out.println("description : "+entry.getDescription());

        }


    } catch (IllegalArgumentException | FeedException | IOException e) {
        e.printStackTrace();
    }

我是否需要将用户名密码放在某处?

更新

我已经做到了

  URL url =  new URL("https://d3ca01230439ce08d4aab0c61810af23:[email protected]/recordings.atom");

    HttpURLConnection httpcon = (HttpURLConnection)url.openConnection();

    String encoding = new sun.misc.BASE64Encoder().encode("username:pass".getBytes());

    httpcon.setRequestProperty  ("Authorization", "Basic " + encoding);

参考方案

当我从浏览器中访问该URL时,它会要求进行基本身份验证。您可以使用ROME做到这一点:

URL feedUrl = new URL(feed)
HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes());
httpcon.setRequestProperty  ("Authorization", "Basic " + encoding);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(httpcon));

您可能不应该使用sun.misc.BASE64Encoder。而是在某个地方找到另一个。

发件人:http://cephas.net/blog/2005/02/09/retrieving-an-rss-feed-protected-by-basic-authentication-using-rome/

Java-搜索字符串数组中的字符串 - java

在Java中,我们是否有任何方法可以发现特定字符串是字符串数组的一部分。我可以避免出现一个循环。例如String [] array = {"AA","BB","CC" }; string x = "BB" 我想要一个if (some condition to tell wheth…

Java:线程池如何将线程映射到可运行对象 - java

试图绕过Java并发问题,并且很难理解线程池,线程以及它们正在执行的可运行“任务”之间的关系。如果我创建一个有10个线程的线程池,那么我是否必须将相同的任务传递给池中的每个线程,或者池化的线程实际上只是与任务无关的“工人无人机”可用于执行任何任务?无论哪种方式,Executor / ExecutorService如何将正确的任务分配给正确的线程? 参考方案 …

JAVA:字节码和二进制有什么区别? - java

java字节代码(已编译的语言,也称为目标代码)与机器代码(当前计算机的本机代码)之间有什么区别?我读过一些书,他们将字节码称为二进制指令,但我不知道为什么。 参考方案 字节码是独立于平台的,在Windows中运行的编译器编译的字节码仍将在linux / unix / mac中运行。机器代码是特定于平台的,如果在Windows x86中编译,则它将仅在Win…

java:继承 - java

有哪些替代继承的方法? java大神给出的解决方案 有效的Java:偏重于继承而不是继承。 (这实际上也来自“四人帮”)。他提出的理由是,如果扩展类未明确设计为继承,则继承会引起很多不正常的副作用。例如,对super.someMethod()的任何调用都可以引导您通过未知代码的意外路径。取而代之的是,持有对本来应该扩展的类的引用,然后委托给它。这是与Eric…

Java:BigInteger,如何通过OutputStream编写它 - java

我想将BigInteger写入文件。做这个的最好方式是什么。当然,我想从输入流中读取(使用程序,而不是人工)。我必须使用ObjectOutputStream还是有更好的方法?目的是使用尽可能少的字节。谢谢马丁 参考方案 Java序列化(ObjectOutputStream / ObjectInputStream)是将对象序列化为八位字节序列的一种通用方法。但…