Skip to main content



      Home
Home » Newcomers » Newcomers » Overwrite an Existing Resource
Overwrite an Existing Resource [message #778320] Thu, 12 January 2012 06:30 Go to next message
Eclipse UserFriend
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 06:32 Go to previous messageGo to next message
Eclipse UserFriend
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 10:56 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Overwrite an Existing Resource [message #781161 is a reply to message #778443] Wed, 18 January 2012 21:38 Go to previous messageGo to next message
Eclipse UserFriend
On 1/12/12 10:56 AM, Russell Bateman wrote:
> 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.
>

Actually, this was an Eclipse Platform related question. Ahsan, try
posting in the Platform forum group, found on the Forums Home page under
the heading "Eclipse Projects."

Eric
Re: Overwrite an Existing Resource [message #788204 is a reply to message #781161] Wed, 01 February 2012 08:43 Go to previous message
Eclipse UserFriend
Thanks both

I managed to get the problem solved by referring to some already existing thread.

Regards
Previous Topic:eclipse formatter and comments (/* */)
Next Topic:help viewer font size
Goto Forum:
  


Current Time: Wed Jul 23 13:42:47 EDT 2025

Powered by FUDForum. Page generated in 0.10749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top