Convert java.net.URI to org.eclipse.emf.common.util.URI

In Java, there are at least two types of URIs:

  • java.net.URI
  • org.eclipse.emf.common.util.URI

I have java.net.URIand you need to use EMF URI. How can I convert the first to the last?

If I try new URI uri = profileUrl.toURI(), I get a message like this:

Type mismatch: cannot convert from java.net.URI to org.eclipse.emf.common.util.URI

I also tried some workaround which will create a line from java.net.URIand with a new line a new EMRI URI ... this will throw an exception not found in the file.

+3
source share
1 answer

-, Java " URI": Java , EMF - , . URI, , , Java URI, ... , ( Eclipse ctrl + shift + T "" "" ).

, java.net.URI org.eclipse.emf.common.util.URI: URI Java , URI . - :

java.net.URI javaURI = profileUrl.toURI();
org.eclipse.emf.common.util.URI emfURI = org.eclipse.emf.common.util.URI.createURI(javaURI.toString());

URI: , Java-. , , org.eclipse.emf.common.util.URI, :

java.net.URI javaURI = profileUrl.toURI();
URI emfURI = URI.createURI(javaURI.toString());
+9

All Articles