Package java.net

Examples of java.net.URL.toURI()


    private ExcelSheetDataModelSource open(String file) throws IOException {
        URL resource = getClass().getResource("data/" + file);
        assertThat(file, resource, not(nullValue()));
        URI uri;
        try {
            uri = resource.toURI();
        }
        catch (URISyntaxException e) {
            throw new AssertionError(e);
        }
        InputStream in = resource.openStream();
View Full Code Here


    }

    private URI uri(String file, String fragment) throws Exception {
        URL url = getClass().getResource(file);
        assertThat(file, url, not(nullValue()));
        URI resource = url.toURI();
        URI uri = new URI(
                resource.getScheme(),
                resource.getUserInfo(),
                resource.getHost(),
                resource.getPort(),
View Full Code Here

            return null;
        }
        String protocol = resource.getProtocol();
        if (protocol.equals("file")) {
            try {
                File file = new File(resource.toURI());
                return toClassPathRoot(aClass, file);
            } catch (URISyntaxException e) {
                LOG.warn(MessageFormat.format(
                        "Failed to locate the library path (cannot convert to local file): {0}",
                        resource), e);
View Full Code Here

                    "There is no marker file on the current classpath: {0}",
                    MARKER_FILE_NAME));
        }
        File file;
        try {
            file = new File(url.toURI());
        } catch (Exception e) {
            throw new IOException(MessageFormat.format(
                    "Failed to detect a default configuration path: {0}",
                    url), e);
        }
View Full Code Here

            URL url = getClass().getResource(fileName);
            assertThat(fileName, url, is(not(nullValue())));

            URI uri;
            try {
                uri = url.toURI();
            } catch (URISyntaxException e) {
                uri = null;
            }

            InputStream in = url.openStream();
View Full Code Here

    private JsonDataModelSource open(String name) {
        URL resource = getClass().getResource(name + ".json");
        assertThat(name, resource, not(nullValue()));
        try {
            return new JsonDataModelSource(
                    resource.toURI(),
                    SIMPLE,
                    new InputStreamReader(resource.openStream(), "UTF-8"));
        } catch (Exception e) {
            throw new AssertionError(e);
        }
View Full Code Here

    @Override
    protected OWLOntology createOntology() {
        try {
            String fileName = getFileName();
            URL resource = getClass().getResource('/' + fileName);
            IRI iri = IRI.create(resource.toURI());
            return m.loadOntologyFromOntologyDocument(iri);
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        } catch (OWLOntologyCreationException e) {
            throw new RuntimeException(e);
View Full Code Here

    }

    private void parseFiles(String base) throws URISyntaxException,
            OWLOntologyCreationException {
        URL url = getClass().getResource(base);
        File file = new File(url.toURI());
        for (File testSuiteFolder : file.listFiles()) {
            if (testSuiteFolder.isDirectory()) {
                for (File ontologyFile : testSuiteFolder.listFiles()) {
                    if (ontologyFile.getName().endsWith(".rdf")
                            || ontologyFile.getName().endsWith(".owlapi")) {
View Full Code Here

 
   String[] getResourceListing(Class clazz, String path) throws URISyntaxException, IOException {
       URL dirURL = clazz.getClassLoader().getResource(path);
       if (dirURL != null && dirURL.getProtocol().equals("file")) {
         /* A file path: easy enough */
         return new File(dirURL.toURI()).list();
       }
      if (dirURL == null) {
         /*
          * In case of a jar file, we can't actually find a directory.
View Full Code Here

          final URI              uri;

          domain = TimeTest.class.getProtectionDomain();
          source = domain.getCodeSource();
          url    = source.getLocation();
          uri    = url.toURI();

          return (uri);
      }

      private static URI getFile(final URI    where,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.