package com.sinosoft.lz.common.print; /** * * @author 徐聪渊 * @E-mail 123xucongyuan@163.com;cw_xcy@hotmail.com * @version 创建时间:2009-5-22 上午11:50:18 * */ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import javax.servlet.ServletContext; import javax.servlet.http.HttpServlet; @SuppressWarnings({ "unused", "serial" }) public class MakeFielsTemplate extends HttpServlet{ public boolean makeFiles(String fileName, String[] str, String fileXmlNum, String path) { try { // 这个读过过程可以参阅 readToBuffer 中的注释 File newfile = new File(path + "\\" + fileName + ".doc"); OutputStream os = new FileOutputStream(newfile); PrintWriter writer = null; try { writer = new PrintWriter(new OutputStreamWriter(os, "utf-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String[] srs = FileFactory.getCaseModel().getCaseXmlList().get(fileXmlNum); String output = new String(); for (int i = 0; i < srs.length - 1; i++) { output = output + srs[i] + str[i]; } output = output + srs[srs.length - 1]; writer.println(output); writer.flush(); // 最后确定要把输出流中的东西都写出去了 os.close(); // os 关闭 return true; } catch (Exception e) { return false; } } // public void makeFiles (String caseID,String fileName,String[] str,String // fileXmlNum) throws IOException { // // 这个读过过程可以参阅 readToBuffer 中的注释 // long a = System.currentTimeMillis(); // OutputStream os = null; // fileName=constantPath.files3+".doc"; // String saveFilePath=constantPath.getRealFilesPath(); // boolean flag=false; // File dir=new File(saveFilePath); // File[] files= dir.listFiles(); // for(int j=0;j