Can I use JavaXPCOM to ask XULRunner to download a file for me?

Carfield Yim <[email protected]>
Newsgroups gmane.comp.mozilla.devel.oji
Organization http://groups.google.com
Message-ID <[email protected]>
Hi, I have an application to get the links of the document from DOM
tree:


			final nsIDOMHTMLCollection list = nsIDOMHTMLDocument.getLinks();
			final List<String> links = new ArrayList<String>();
			for (int i = 0; i < list.getLength(); i++) {
				final String nodeValue =
list.item(i).getAttributes().getNamedItem("href").getNodeValue();
				if (!nodeValue.contains("://")) {
					final String link = url.getProtocol() + "://" + url.getHost() +
"/" + nodeValue;
					links.add(link);
				}
			}

Then, I download the link using following code:


		for (Iterator<String> iterator = links.iterator();
iterator.hasNext();) {
			final String link = iterator.next();
			final File file = new File(USER_DIR,
link.substring(link.lastIndexOf('/')).replace("?", "_"));
			try {
				file.createNewFile();
				IOUtils.copy(new URL(link).openStream(), new
FileOutputStream(file));
				inList.add(file.getAbsolutePath());
			} catch (Exception e) {
				System.err.println(file.getAbsolutePath());
				e.printStackTrace();
			}
		}


However, this probably don't work if the site require user login to
view the page, because every new URL(link).openStream() will start a
new session at web server. Can I call XULRunner to download the link
to suitable place??
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.