public File runDiff(File oldFile,File newFile,File compareFile,Logger log)
{
//oldFileName=(oldFile.getPath()).replace('\\', '/');
oldFileName=oldFile.getPath();
System.out.println("filename"+oldFileName);
//newFileName=(newFile.getPath()).replace('\\', '/');
newFileName=newFile.getPath();
String[] commands=new String[3];
commands[0]="diff";
commands[1]=oldFileName;
commands[2]=newFileName;
log.info("command"+commands.toString());
try
{
Process proc=Runtime.getRuntime().exec(commands);
InputStream in = proc.getInputStream();
InputStreamReader reader = new InputStreamReader(in);
BufferedReader bufferedReader = new BufferedReader(reader);
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(compareFile));
char buf[] = new char[1024]; //字符缓冲区
int len;
while ((len = bufferedReader.read(buf)) != -1)
{
bufferedWriter.write(buf, 0, len);
}
bufferedWriter.flush();
bufferedReader.close();
bufferedWriter.close();
}catch(IOException e){
log.error("数据比较出错"+ e.toString());
e.printStackTrace();
}
return compareFile;
}