我想删除该文件或复制由该程序创建的文件,它不允许我需要解决方案
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();
}
}
}
答案 0 :(得分:0)
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
{
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));
htmlFile.close();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
}
}
}