123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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<files.length;j++){
- // if(files[j].getName().equals(caseID)){
- // flag=true;
- // break;
- // }
- // }
- // if(!flag){
- // File newfile=new File(saveFilePath+"\\"+caseID,fileName);
- // newfile.getParentFile().mkdir();
- // try {
- // os=new FileOutputStream(newfile);
- // } catch (FileNotFoundException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }else if(flag){
- // File newfile=new File(saveFilePath+"\\"+caseID,fileName);
- // try {
- // os=new FileOutputStream(newfile);
- // } catch (FileNotFoundException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- // PrintWriter writer = null;
- // try {
- // writer = new PrintWriter(new OutputStreamWriter(os,"utf-8"));
- // } catch (UnsupportedEncodingException e) {
- // // TODO Auto-generated catch block
- // 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 关闭
- //
- // }
- }
|