有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何传递getClass。getClassLoader()。将getResourceAsStream()值转换为FileOutputStream

我使用返回Inputstream类型的getClass.getClassLoader().getResourceAsStream("abc.txt")来获取工作正常的文件路径。现在我需要将文件路径传递给streamresult,但它有一个构造函数:StreamResult(new FileOutputStream())。如何将inputstream类型的文件路径传递给streamresult

我正在读取一个xml文件,并在jsp文件中显示该数据。在jsp文件中,我设置了一个将数据写回xml文件的标志TransformerFactory.newInstance().newTransformer().transform(new DOMSource(ds.getOwnerDocument()), new StreamResult(new FileOutputStream(pathFile)));。因此,pathFile是我要向其写入数据的文件。我就是不能通过abc考试。txt代替pathFile,因为我需要Absolute文件路径


共 (0) 个答案