Example usage for java.net URL toURI

List of usage examples for java.net URL toURI

Introduction

In this page you can find the example usage for java.net URL toURI.

Prototype

public URI toURI() throws URISyntaxException 

Source Link

Document

Returns a java.net.URI equivalent to this URL.

Usage

From source file:org.apache.taverna.scufl2.translator.scufl.processorelement.StringConstantExtensionParser.java

@Override
public List<URI> getAdditionalSchemas() {
    URL stringConstantXsd = getClass().getResource(STRINGCONSTANT_XSD);
    try {/*from  www.j av a  2s  .c om*/
        return Arrays.asList(stringConstantXsd.toURI());
    } catch (URISyntaxException e) {
        throw new IllegalStateException("Can't find String Constant schema " + stringConstantXsd);
    }
}

From source file:com.boundary.sdk.event.esper.EsperRouteTest.java

@Test
public void testReadURIClasspath() throws IOException, URISyntaxException {
    ClassLoader classLoader = this.getClass().getClassLoader();
    URL url = classLoader.getResource("test-esper-query-load.json");
    File file = new File(url.toURI());
    assertTrue("check if file", file.isFile());
    assertTrue("check file exists", file.exists());
}

From source file:org.openscore.lang.compiler.modeller.transformers.DoTransformerTest.java

@Before
public void init() throws URISyntaxException {
    URL resource = getClass().getResource("/flow_with_data.yaml");
    File file = new File(resource.toURI());
    ParsedSlang parsedSlang = yamlParser.parse(SlangSource.fromFile(file));
    List<Map<String, Map>> flow = (List<Map<String, Map>>) parsedSlang.getFlow()
            .get(SlangTextualKeys.WORKFLOW_KEY);
    for (Map<String, Map> task : flow) {
        if (task.keySet().iterator().next().equals("CheckWeather")) {
            doInputsMap = (LinkedHashMap) task.values().iterator().next().get(SlangTextualKeys.DO_KEY);
            break;
        }//from  www  .  j a  v  a 2  s .  c om
    }
}

From source file:com.apexxs.neonblack.setup.TMBorderLoader.java

public int load(SolrServer server) {
    int count = 0;
    try {/*w  w w. j av a2s. c om*/
        URL url = TMBorderLoader.class.getResource("/TM_WORLD_BORDERS-0.3.csv");
        File file = new File(url.toURI());

        BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
        String line;

        r.readLine();

        while ((line = r.readLine()) != null) {
            BorderData bd = new BorderData();

            String[] tokens = line.split(";");
            bd.fips = tokens[1];
            bd.iso2 = tokens[2];
            bd.iso3 = tokens[3];
            bd.name = tokens[5];
            bd.wkt = tokens[0].replace("\"", StringUtils.EMPTY);
            bd.id = MD5Utilities.getMD5Hash(bd.wkt);
            bd.shapeType = "adm0";
            server.addBean(bd);
            System.out.println("Added " + bd.name);
            count++;
        }
        r.close();
    } catch (Exception ex) {
        System.out.println("Error in TMBorderLoader.load()");
        ex.printStackTrace();
    }
    return count;
}

From source file:RdfSplitterTest.java

@Test
public void rdfFragment() throws ParseException, IOException, FileNotFoundException, URISyntaxException {
    //        String inPath = "/Users/gaignard/Documents/Experiences/ExpeFedBench-2013/FedBench-DS-2013/kegg/KEGG-2010-11";

    URL in = JenaLoadingTest.class.getClassLoader().getResource("fromKEGG");
    File f = new File(in.toURI());
    String inPath = f.getAbsolutePath();

    String c1 = "-i " + inPath + " " + "-o /tmp/frag -n 4";

    //        String c2 = "-i "+inPath
    //                + "-o /tmp/frag";

    //        String c3 = "-i "+inPath
    //                + "-o /tmp/frag -n 4 -f 10 -f 20";

    String c4 = "-i " + inPath + " " + "-o /tmp/frag -f 10 -f 15";

    String c5 = "-i " + inPath + " " + "-o /tmp/frag -f 10 -tdb";

    String c6 = "-i " + inPath + " "
            + "-o /tmp/frag -p http://bio2rdf.org/ns/kegg -p http://bio2rdf.org/ns/bio2rdf";

    ArrayList<String> commandLines = new ArrayList<String>();
    commandLines.add(c1);/*from   w ww.  j a v a  2 s .  c o m*/
    //        commandLines.add(c2);
    //        commandLines.add(c3);
    commandLines.add(c4);
    commandLines.add(c5);
    commandLines.add(c6);

    for (String c : commandLines) {
        RdfSplitter.main(c.split(" "));
    }
}

From source file:com.thingtrack.konekti.report.internal.ReportManagerServiceImpl.java

@SuppressWarnings("unused")
@Override/*from  w  w w  . j  av a  2s. c  o m*/
public JasperPrint executeReport(String code, Map<String, Object> parameters) throws Exception {
    // get  report to execute
    Report report = reportService.getByCode(code);

    if (report == null)
        throw new Exception("The Report with code " + code + " not exist!");

    // get connection from jpa transaction manager to inject to jasper report template
    Connection connection = entityManager.unwrap(java.sql.Connection.class);

    if (connection == null)
        throw new Exception("We can not get the JPA connection!");

    // get report path from the fragment report templates bundle
    String pathReport = DEFAULT_REPORT_PATH + report.getCode() + "/" + report.getFileName();
    URL urlResource = getClass().getResource(pathReport);

    File fileResource = new File(urlResource.toURI());

    if (fileResource == null)
        throw new Exception("The report templeate on " + pathReport + " not exist!");

    // load jasper report xml template
    JasperDesign jasperDesign = JRXmlLoader.load(fileResource);

    // compile jasper report template
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

    // generate jasper report
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, connection);

    return jasperPrint;

}

From source file:org.apache.streams.rss.test.SyndEntryActivitySerizlizerTest.java

public void testProviderUrl(Provider provider) {
    URL url = null;

    try {//from   w w w.  ja va  2 s.c  o  m
        url = new URL(provider.getUrl());
        url.toURI();
    } catch (Exception e) {
        System.out.println("Threw an exception while trying to validate URL: " + provider.getUrl());
    }

    assertNotNull(url);
}

From source file:com.boundary.sdk.event.esper.QueryListTest.java

@Test
public void testReadURIClasspath() throws IOException, URISyntaxException {
    ClassLoader classLoader = this.getClass().getClassLoader();
    URL url = classLoader.getResource(QUERY_LIST_FILE);
    File file = new File(url.toURI());
    assertTrue("check if file", file.isFile());
    assertTrue("check file exists", file.exists());
}

From source file:com.fizzed.rocker.reload.ReloadTest.java

@Test
public void reload() throws Exception {

    // render initial
    String out = Rocker.template("views/index.rocker.html", "Home", "Joe").render().toString();

    assertThat(out, containsString("<h1>Hi, Joe!</h1>"));

    // to find path reliably of source file, we'll take something on classpath
    // for this project and then do something relative to it
    URL logbackUrl = ReloadTest.class.getResource("/logback.xml");
    File projectDir = new File(logbackUrl.toURI()).getParentFile().getParentFile().getParentFile();

    File currentTemplateFile = new File(projectDir, "src/test/java/views/index.rocker.html");

    FileInputStream fis = new FileInputStream(currentTemplateFile);

    String currentTemplate = IOUtils.toString(fis, "UTF-8");

    String newTemplate = currentTemplate.replace("<h1>Hi, @name!</h1>", "<h1>Hi, @name!?!</h1>");

    try {//from   w  ww  .  j  a v  a 2s . c  o  m
        FileOutputStream fos = new FileOutputStream(currentTemplateFile);
        IOUtils.write(newTemplate, fos, "UTF-8");

        out = Rocker.template("views/index.rocker.html", "Home", "Joe").render().toString();

        assertThat(out, containsString("<h1>Hi, Joe!?!</h1>"));

    } finally {
        // restore template back...
        FileOutputStream fos = new FileOutputStream(currentTemplateFile);
        IOUtils.write(currentTemplate, fos, "UTF-8");
    }

    // since we base reloading on timestamp, need to force something
    // different since these tests run so quickly
    currentTemplateFile.setLastModified(System.currentTimeMillis() + 5000);

    // try the restored file one more time
    out = Rocker.template("views/index.rocker.html", "Home", "Joe").render().toString();

    assertThat(out, containsString("<h1>Hi, Joe!</h1>"));
}

From source file:net.sourceforge.dita4publishers.tools.dxp.MapCopyingBosVisitor.java

public void visit(BosMember member) throws BosException {
    String relative = AddressingUtil.getRelativePath(member.getDataSourceUri(), baseUri);
    URL resultUrl;
    try {//from ww w .ja v a 2  s . c  o  m
        resultUrl = new URL(outputUrl, relative);
        File resultFile = new File(resultUrl.toURI());
        resultFile.getParentFile().mkdirs();
        log.info("Creating result file \"" + resultFile.getAbsolutePath() + "\"...");
        IOUtils.copy(member.getInputStream(), new FileOutputStream(resultFile));
    } catch (Exception e) {
        throw new BosException(e);
    }

}