0

I need to create method, which can download 2 newest .xml files (or just extract URL to these files) from this website: http://rss.nbp.pl/kursy/xml2/2015/a/. I know how to do it with speciefied URL, but I have no idea how to automatically download newest files.

Actually I've got this:

    URL website = new URL(xmlFileUrl);
    ReadableByteChannel rbc = Channels.newChannel(website.openStream());
    FileOutputStream fos = new FileOutputStream("src/com/sh00x/files/kursy2.xml");
    fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

Thanks for any help, Greetings

Piyush Gupta
  • 2,181
  • 3
  • 13
  • 28
Custodian
  • 21
  • 5
  • http://stackoverflow.com/questions/238547/how-do-you-programmatically-download-a-webpage-in-java Check out @BalusC response on JSoup – Chris Jan 04 '16 at 15:49
  • Thanks! I will check this out. – Custodian Jan 04 '16 at 16:03
  • You can use [Xpath](http://stackoverflow.com/questions/3361263/library-to-query-html-with-xpath-in-java#answer-14188344) with something like `//a[contains(., '.xml')][position() >= last() - 1]` to get the two last (rows) XML url – Duffydake Jan 04 '16 at 16:24

0 Answers0