1

I am trying to save an EMF model with extension .xmi. But unable to do so, as I couldn't see any error neither in development nor in runtime.

If I save it at default location which is platform:/resource/CompanyToIT/instances/corr-2019_08_31-19_24_52.xmi it get's saved. But when I try to select a different location like C:\Users\PC\Desktop\XMI it doesn't save it, as I couldn't see the file at the location (I also tried adding platform: to the path, no luck).

Below is my function which I am using. This gets called from runtime environment UI. UI passes the path along with resource to this function.

private void saveModel(Resource r, String time, String newLocation) throws IOException {
        String newPath;
        URI newUri;

        newPath = FilenameUtils.getFullPath(newLocation);           
        newPath += FilenameUtils.getBaseName(newLocation) + "-";
        newPath += time + "." + FilenameUtils.getExtension(newLocation);            
        newUri = URI.createURI(newPath);

        r.setURI(newUri);
        r.save(null);
}

Any help would be appreciated. Thanks!

  • Please read [mcve] and enhance your question accordingly. For example: "does not work" isn't a working problem description. We also have no idea in what context that method you show here got called! – GhostCat Sep 01 '19 at 12:34
  • I have tried to add more details into it. – Asher Ahsan Sep 01 '19 at 12:45

1 Answers1

1

You want to use URI.createFileURI(String that is a filepath).

user1292456
  • 778
  • 4
  • 12