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 {
        /* 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();
      }
    }
 }
4

1 回答 1

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
{

}
}
}
于 2012-09-04T08:57:24.333 回答