Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Overwrite an Existing Resource
Overwrite an Existing Resource [message #778320] Thu, 12 January 2012 11:30 Go to next message
Ahsan Missing name is currently offline Ahsan Missing nameFriend
Messages: 10
Registered: December 2011
Location: Munich, Germany
Junior Member

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 Go to previous messageGo to next message
Ahsan Missing name is currently offline Ahsan Missing nameFriend
Messages: 10
Registered: December 2011
Location: Munich, Germany
Junior Member

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 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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] Thu, 19 January 2012 02:38 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
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 13:43 Go to previous message
Ahsan Missing name is currently offline Ahsan Missing nameFriend
Messages: 10
Registered: December 2011
Location: Munich, Germany
Junior Member

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: Thu Apr 25 04:54:41 GMT 2024

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

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

Back to the top