资源描述:
《web项目部署快捷类》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、创建下面的一个java类packagecom.liuxin.deploy;importjava.io.BufferedReader;importjava.io.File;importjava.io.FileReader;importjava.io.FileWriter;publicclassDeploy{/***@paramargs*/publicstaticvoidmain(String[]args)throwsException{creatFile("D:\workspace-app\deployFile\src\com\wangwei\deplo
2、y","filelist.txt","D:\workspace-app\diplomacyinfo","G:eimengtemps");//creatFile("G:\fileList","filelist1.txt","D:\workspace-app\epmshbr","G:\hulunbeiertemps");}/***输出地址和原文件地址中不能包含中文或全角字符*@paramfileListPath要读取的文件列表*@paramfileName文件名称(TXT文件),文件内容不能存在空行*@paramhead工程目录只放到工作区目录即可*
3、@paramcopyTo存放地址*@throwsException*/publicstaticvoidcreatFile(StringfileListPath,StringfileName,Stringhead,StringcopyTo)throwsException{Filefile=newFile(fileListPath+"\"+fileName);FileReaderfr=newFileReader(file);Filenewfile=newFile(copyTo);if(!newfile.exists()){newfile.mkdirs();}File
4、Writerfw=newFileWriter(newFile(copyTo+"\GetCMD.cmd"));FileWriterfw1=newFileWriter(newFile(copyTo+"\DeployCMD.cmd"));BufferedReaderbr=newBufferedReader(fr);Stringtemp=br.readLine();while(temp!=null){createGetFile(temp,head,copyTo,fw);creatDeployFile(temp,copyTo,fw1);temp=br.readLine(
5、);}fw1.flush();fw1.close();fw.flush();fw.close();br.close();fr.close();}/***把java文件关联的class也取出来*@paramjavaPath*@paramfw*@paramfilename*@throwsException*/privatestaticvoidgetJavaClass(StringjavaPath,FileWriterfw,Stringfilename)throwsException{if(javaPath.lastIndexOf(".java")==-1){retur
6、n;}Stringpath="copy""+javaPath.replaceAll("src","WebRoot\\WEB-INF\\classes").replaceAll(".java",".class")+""""+filename.replaceAll(".java",".class")+""";fw.write(path);}/***取得filelist中的更新文件*@paramtemp*@paramhead*@paramcopyTo*@paramfw*@throwsException*/privatestaticvoidcreate
7、GetFile(Stringtemp,Stringhead,StringcopyTo,FileWriterfw)throwsException{intindex=temp.indexOf("//");if(index>-1){temp=temp.substring(0,index).trim();}Stringfilename="\"+temp.substring(temp.lastIndexOf("/")+1);temp=head+temp;temp=temp.replaceAll("/","\\");filename=copyTo+filename;fw
8、.writ