Overwrite an Existing Resource [message #778320] |
Thu, 12 January 2012 11:30 |
|
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
|
|
|
Re: Overwrite an Existing Resource [message #778321 is a reply to message #778320] |
Thu, 12 January 2012 11:32 |
|
For my output one possible solution is
Resource outResource = new ResourceSetImpl().createResource(outputURI);
but I dont want to create a resource. I want to add contents to an already existing resource.
Thanks
|
|
|
Re: Overwrite an Existing Resource [message #778443 is a reply to message #778320] |
Thu, 12 January 2012 15:56 |
|
On 12-Jan-12 04:30, Ahsan Mising name wrote:
> Hello Everyone
>
> [snip]
> If I am on a wrong forum please guide me. Ill appreciate your help.
>
> Regards
You're right. This is a Java question. My suggestions would be a)
javaranch.com or b) stackoverflow.com.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.11663 seconds