Overwrite an Existing Resource [message #778320] |
Thu, 12 January 2012 06:30  |
Eclipse User |
|
|
|
Hello Everyone
I am new field of Java and eclipse. Unfortunately I can not figure out a possible way of overwriting an existing resource file using Java. I want to override because I need to make some changes in the namespace of of transformed resource file (xml file) manually in the file and then perform the transformation again. Overwriting enables the transformed file to recognize correct namespace and I get a valid output.
I am using the following code
ExecutionDiagnostic result = executor.execute(context, input, output);
if(result.getSeverity() == Diagnostic.OK)
{
List<EObject> outObjects = output.getContents();
URI outputURI = URI.createURI("platform:/resource/artop-autosar".concat(inputmodel.replace(".uml", ".xml")));
Resource outResource = new ResourceSetImpl().getResource(outputURI,false);
outResource.getContents().addAll(outObjects);
try {
outResource.save(Collections.emptyMap());
System.out.println(inResource);
System.out.println(outResource);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
but I get an exception of null pointer at "outResource.getContents().addAll(outObjects);"
If I am on a wrong forum please guide me. Ill appreciate your help.
Regards
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10749 seconds