/*
* Author: sambafeng
* date:2011-04-25
*/
/*
* TODO:auto create patches for script language programe,such as shell,ruby,perl,python
*/
package util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class AutoCreatePatch{
/*
* TODO:create the patches by the key words:sourcedir,destdir,patchTxtName
*/
@SuppressWarnings("unchecked")
public void createPatches(String pre_sourcedir,String pre_destdir,String patchTxtName) throws FileNotFoundException, IOException{
List num=new ArrayList();
HashMap hm=new HashMap();
String suff_pos_name;
/*empty the destdir */
deletefile(pre_destdir);
System.out.println("Cleaning:"+pre_destdir);
new File(pre_destdir).mkdir();
System.out.println("Mkdir:"+pre_destdir+" finished!");
try{
BufferedReader in = new BufferedReader(new FileReader(patchTxtName));
String str;
int row = 0;
int row_pre=0;
while((str = in.readLine())!= null){
row++;
row_pre=row-1;
hm.put(row,str);
if(str.equals("===================================================================")){
num.add(row_pre);
}
}
for(int i=0;i<num.size();i++){
suff_pos_name=(String) hm.get(num.get(i));//Index: basefunction/base_resources.rb
String fullfilename=suff_pos_name.substring(suff_pos_name.indexOf("Index: ")+7);//ct/fd/
File fullsourceFile=new File(pre_sourcedir+"/"+fullfilename);//source file
File fulldestFile=new File(pre_destdir+"/"+fullfilename);//dest file
// System.out.println(fulldestFile.getParentFile());
String fulldestDir=fulldestFile.getParent().toString();
new File(fulldestDir).mkdirs();
copyFile(fullsourceFile,fulldestFile);
System.out.println("Copy "+fullsourceFile+" to "+fulldestFile);
}
in.close();
System.out.println("Make Patches finished! Count "+num.size()+" Files");
}catch(IOException e){
System.out.println("error");
}
}
/*
* copy the file from sourceFile to destFile
*
*/
public static void copyFile(File sourceFile,File destFile) throws IOException{
FileInputStream input = new FileInputStream(sourceFile);
BufferedInputStream inBuff=new BufferedInputStream(input);
FileOutputStream output = new FileOutputStream(destFile);
BufferedOutputStream outBuff=new BufferedOutputStream(output);
byte[] b = new byte[1024 * 5];
int len;
while ((len =inBuff.read(b))!=-1){
outBuff.write(b,0,len);
}
outBuff.flush();
inBuff.close();
outBuff.close();
output.close();
input.close();
}
public static boolean deletefile(String destDir)throws FileNotFoundException, IOException {
try {
File file = new File(destDir);
if (!file.isDirectory()) {
file.delete();
} else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i=0;i<filelist.length; i++) {
File delfile = new File(destDir+"\\"+filelist[i]);
if (!delfile.isDirectory()){
delfile.delete();
}
else if(delfile.isDirectory()) {
deletefile(destDir+"\\"+filelist[i]);
}
}
file.delete();
}
} catch (FileNotFoundException e) {
System.out.println("Exception:" + e.getMessage());
}
return true;
}
public static void main(String args[]) throws IOException{
AutoCreatePatch ap=new AutoCreatePatch();
ap.createPatches("D:\\workspace\\Ctrip_AutomationTest","E:/patch/Ctrip_AutomationTest","E:\\patch.txt");
}
}
分享到:
相关推荐
Hugin编译所需文件hugin_patches.zip,可编译成c++工程文件,用于图像拼接。是很好的拼接软件。
QuickTest Professional 11 Patches 全部更新补丁(不包含语言包) http: relevantcodes com qtp 11 0 patches Save to QC ALM Error Fixed 10 18 2012 QTP 00925 This patch fixes a problem that ...
PC-lint Patches 补丁,运用方式,解压后得到rtp文件,使用patch lp9-a-b.rtp 类似命令即可打补丁。共三个文件,两个补丁,一个patch.exe pcliente,CSDN有,自行寻找。
工作流activiti开发时 图形界面报错所需要的包 亲测可用
将数据集图像分块提取,分为两种策略。param中设置图像块大小与步长等参数。然后运s01生成数据集的npy文件,再运行s02提取图像块。图像块的提取策略再patch_extractor.py文件中设置,一种是随机,一种是按得分高低。
2.请注意:myeclipse2015不需要安装patches,只需要安装activiti即可。 3.如果是myeclipse10等低版本,那么请将patches插件也安装,绝对可以用。 重要的事情说三遍,win10亲测可用,win10亲测可用,win10亲测可用。 ...
cen_patches_0.50_of.dat openface model model/patch_experts/cen_patches_0.50_of.dat
myeclipse的activiti插件,
guestd_patches.pkg分辨率
Mac OS X 虚拟机不能这是由于没有显卡驱动。下载 VMsvga2_v1.2.5_OS_10.9.pkg (显卡驱动)和 guestd_patches.pkg(自动调整分辨率补丁),然后安装,重启,再试试全屏,发现可以了。
项目增量打包神器:全自动web增量打包发版,支持git/svn,支持多模块项目
补丁格式补丁只是 JSON 文件,其中包含要应用的补丁列表,如下所示: { " patches " : [ { " find " : " regex_goes_here " , " replace " : " replace_with " } ]} find 值可以是一个简单的字符串来查找和替换,也...
QuickTest Professional 11 Patches 全部更新补丁(不包含语言包) http: relevantcodes com qtp 11 0 patches Run Tests from ALM Server 06 25 2012 QTP 00919 This patch enables you to run QuickTest...
patches疯狂刷机 凤凰刷机用
patches_G608ZCHF2.rarpatches_G608ZCHF2.rarpatches_G608ZCHF2.rarpatches_G608ZCHF2.rarpatches_G608ZCHF2.rarpatches_G608ZCHF2.rar
QuickTest Professional 11 Patches 全部更新补丁(不包含语言包) http: relevantcodes com qtp 11 0 patches Run Tests from ALM Server 01 18 2013 QTP 00953 This patch enables you to run QuickTest...
凯立德主程序包各个文件作用详解 ,完整的凯立德地图更新包patches.ndz内有8个文件,由两部分组成: 地图更新包文件(5个文件),实际提供的凯立德地图更新包的就是这5个文件:地图更新的道路数据Patches文件夹内有2...
cen_patches_0.25_of.dat openface model model/patch_experts/cen_patches_0.25_of.dat
Patches for Envi 5.1 + Envi Lidar 5.1 好用,破解方便
当尚未设置该文件时,它还会将该文件添加到composer.json ,并添加一个post-update-cmd挂钩以自动更新补丁文件。 这取决于magento/quality-patches和vaimo/composer-packages 。安装与使用 composer require ...