【发布时间】:2012-09-04 08:49:59
【问题描述】:
我想删除文件或复制此程序创建的文件,但它不允许我需要解决方案
package xml2html;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class Xml2HtmlConverter {
public static void main(String[] args, String xmlpath) {
pathmethod(xmlpath);
}
public static void pathmethod(String xmlpath) {
try {
/* converting the file using xls */
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslDoc = new StreamSource("D:/xmlautomation/stylesheet.xsl");
Source xmlDoc = new StreamSource(xmlpath);
String outputFileName = "D:/xmlautomation/output.html";
OutputStream htmlFile = new FileOutputStream(outputFileName);
Transformer transformer = tFactory.newTransformer(xslDoc);
transformer.transform(xmlDoc, new StreamResult(htmlFile));
} catch(Exception e) {
e.printStackTrace();
}
}
}
【问题讨论】:
-
您在代码中的哪个位置尝试删除哪个文件?
-
public static void main(String[] args, String xmlpath)??? -
我使用 html 添加了一个小 ui,用于浏览 xml 文件并将文件路径发送到 servlet 并从那里发送到上述类,转换后我将页面重定向到另一个 html,显示转换成功跨度>
-
我找到了答案,感谢您花费宝贵的时间来调查我的问题@nfechner