



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
创建下面的一个java类package com.liuxin.deploy;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.FileWriter;public class Deploy /* * param args */public static void main(String args) throws ExceptioncreatFile(D:workspace-appdeployFilesrccomwangweideploy,filelist.txt,D:workspace-appdiplomacyinfo,G:neimengtemps);/creatFile(G:fileList,filelist1.txt,D:workspace-appepmshbr,G:hulunbeiertemps); /* * 输出地址和原文件地址中不能包含中文或全角字符 * param fileListPath 要读取的文件列表 * param fileName 文件名称(TXT文件),文件内容不能存在空行 * param head 工程目录 只放到工作区目录即可 * param copyTo 存放地址 * throws Exception */public static void creatFile(String fileListPath,String fileName,String head,String copyTo) throws ExceptionFile file = new File(fileListPath+fileName);FileReader fr = new FileReader(file);File newfile = new File(copyTo);if(!newfile.exists()newfile.mkdirs();FileWriter fw = new FileWriter(new File(copyTo+GetCMD.cmd);FileWriter fw1 = new FileWriter(new File(copyTo+DeployCMD.cmd);BufferedReader br = new BufferedReader(fr);String temp = br.readLine();while(temp != null)createGetFile(temp,head,copyTo,fw);creatDeployFile(temp,copyTo,fw1);temp = br.readLine();fw1.flush();fw1.close();fw.flush();fw.close();br.close();fr.close();/* * 把java文件关联的class也取出来 * param javaPath * param fw * param filename * throws Exception */private static void getJavaClass(String javaPath,FileWriter fw,String filename) throws Exception if(javaPath.lastIndexOf(.java) = -1)return;String path = copy + javaPath.replaceAll(src, WebRootWEB-INFclasses).replaceAll(.java, .class) + + filename.replaceAll(.java, .class) + n;fw.write(path);/* * 取得filelist中的更新文件 * param temp * param head * param copyTo * param fw * throws Exception */private static void createGetFile(String temp,String head,String copyTo,FileWriter fw) throws Exception int index = temp.indexOf(/);if(index-1)temp = temp.substring(0,index).trim();String filename = +temp.substring(temp.lastIndexOf(/)+1);temp = head+temp;temp = temp.replaceAll(/, );filename = copyTo+filename;fw.write(copy + temp + + filename+n);getJavaClass(temp,fw,filename);/* * 创建部署文件 */private static void creatDeployFile(String temp,String copyTo,FileWriter fw1) throws Exception int index = temp.indexOf(/);if(index-1)temp = temp.substring(0,index).trim();temp = copyTo+temp;temp = temp.replaceAll(/, );/生成对应包下的java文件new File(temp.substring(0,temp.lastIndexOf().mkdirs();/生成对应包下的class文件String classpath = temp.replaceAll(src, WebRootWEB-INFclasses);new File(classpath.substring(0,classpath.lastIndexOf().mkdirs(); String filename = copyTo+temp.substring(temp.lastIndexOf()+1);fw1.write(copy + filename + + temp+n);DeployJavaClass(temp,fw1,filename);/fw1.write(copy + filename + + temp +n);/* * 创建部署文件CLASS文件 * param javaPath * param fw * param filename * throws Exception */private static void DeployJavaClass(String javaPath,FileWriter fw,String filename) throws Exception if(javaPath.lastIndexOf(.java) = -1)return;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论