[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Problem in Merging two java files Using IStorageMerger

Hi All,
I am trying to merge java files using IStorageMerger API.
I am calling DelegatingStorageMerger.merge();

I am trying with the below code

private String merge(File srcTarget, File srcOldFile) throws CoreException {

IPath projectIPath = new Path(srcTarget.getAbsolutePath());


IFile file = ResourcesPlugin.getWorkspace().getRoot ().getFileForLocation(projectIPath);
file.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

IPath rightprojectIPath = new Path(srcOldFile.getAbsolutePath());
IFile rightfile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(rightprojectIPath);
rightfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());


IStorageMerger delegatingStorageMerger=DelegatingStorageMerger.createTextMerge();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
File otherFile= null;
try {
otherFile = FileUtil.write(srcTarget.getParentFile().getPath() ,srcTarget.getName()+"aa", "");
} catch (FrameworkException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IPath otherIPath = new Path(otherFile.getAbsolutePath());
IFile otherIfile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocatio(otherIPath);
otherIfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

IStatus mergeStatus = delegatingStorageMerger.merge(byteArrayOutputStream , file.getCharset(), rightfile, file,otherIfile,new NullProgressMonitor());

return byteArrayOutputStream.toString();
}


But merge is not happening.
Could anybody please help me in solving this issue as it is verymuch important in this project and also in recession time.


Thanks And Regards in Advance
Debasis