我想创建一个XML文件,它将作为下载链接提供给用户(Wicket和TransformerFactory for XSLT)。 目前,我使用File类。但是,我不想在服务器上创建文件。该文件应该只存在于内存中。有人可以告诉我怎样才能做到这一点? 谢谢!内存中的XML文件而不是磁盘上的文件
我当前的代码:
Reader reader = new StringReader("DATA");
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("EXCEL.xsl"));
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
File file= new File("FILE.xml");
transformer.transform(new StreamSource(reader), new StreamResult(new FileOutputStream(file)));
其他类:
File file = new File("file");
add(new DownloadLink("download", file, "XML.xml"));
就我所知,使用File类,您没有机会完成此操作。 – cgon