Example usage for java.io File toURI

List of usage examples for java.io File toURI

Introduction

In this page you can find the example usage for java.io File toURI.

Prototype

public URI toURI() 

Source Link

Document

Constructs a file: URI that represents this abstract pathname.

Usage

From source file:com.navercorp.pinpoint.bootstrap.java9.module.JarFileAnalyzerTest.java

@Test
public void jarFileToURI() throws IOException {
    URL url = CodeSourceUtils.getCodeLocation(Logger.class);
    logger.debug("url:{}", url);

    JarFile jarFile = new JarFile(url.getFile());
    logger.debug("jarFile:{}", jarFile.getName());
    File file = new File(jarFile.getName());
    logger.debug("url1:{}", file.toURI());
}

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

/**
 * @param rootUrl URL of the root map //from  ww w  . j av  a 2s.c  o m
 * @param outputDir
 * @throws MalformedURLException 
 */
public MapCopyingBosVisitor(File outputDir) throws MalformedURLException {
    super(log);
    this.outputUrl = outputDir.toURI().toURL();
}

From source file:com.asakusafw.runtime.util.hadoop.ConfigurationProvider.java

/**
 * Computes the default Hadoop configuration path.
 * @param environmentVariables the current environment variables
 * @return the detected configuration path, or {@code null} if the configuration path is not found
 * @since 0.6.0//w  ww . jav a  2  s.c  o  m
 */
public static URL getConfigurationPath(Map<String, String> environmentVariables) {
    if (environmentVariables == null) {
        throw new IllegalArgumentException("environmentVariables must not be null"); //$NON-NLS-1$
    }
    File conf = getConfigurationDirectory(environmentVariables);
    if (conf == null) {
        // show warning only the first time
        if (SAW_HADOOP_CONF_MISSING.compareAndSet(false, true)) {
            LOG.warn("Hadoop configuration path is not found");
        }
        return null;
    }
    if (conf.isDirectory() == false) {
        LOG.warn(MessageFormat.format(
                "Failed to load default Hadoop configurations ({0} is not a valid installation path)", conf));
        return null;
    }
    try {
        return conf.toURI().toURL();
    } catch (MalformedURLException e) {
        LOG.warn(MessageFormat.format(
                "Failed to load default Hadoop configurations ({0} is unrecognized to convert URL)", conf), e);
        return null;
    }
}

From source file:com.jamesashepherd.sshproxyj.core.Start.java

private String getSpringConfigURL() throws StartException {
    File f = new File(home, props.getProperty(SPRING_XML_PROPERTY));
    try {//from  w  ww .j a  va  2 s . c o m
        return f.toURI().toURL().toString();
    } catch (MalformedURLException e) {
        throw new StartException("Failed to get Spring config URL", e);
    }
}

From source file:io.github.seleniumquery.browser.BrowserFunctions.java

/**
 * Opens the given file as a URL in the browser.
 *
 * @param fileToOpenAsURL The file to be opened as URL.
 * @return A self reference.//w  w w  .j  a v a  2s. c o m
 *
 * @since 0.9.0
 */
public BrowserFunctions url(File fileToOpenAsURL) {
    return url(fileToOpenAsURL.toURI().toString());
}

From source file:com.googlecode.jsonschema2pojo.integration.ref.AbsoluteRefIT.java

@Test
public void absoluteRefIsReadSuccessfully() throws ClassNotFoundException, NoSuchMethodException, IOException {

    File schemaWithAbsoluteRef = createSchemaWithAbsoluteRef();

    File generatedOutputDirectory = generate(schemaWithAbsoluteRef.toURI().toURL(), "com.example");
    Class<?> absoluteRefClass = compile(generatedOutputDirectory).loadClass("com.example.AbsoluteRef");

    Class<?> addressClass = absoluteRefClass.getMethod("getAddress").getReturnType();

    assertThat(addressClass.getName(), is("com.example.Address"));
    assertThat(addressClass.getMethods(), hasItemInArray(hasProperty("name", equalTo("getPostal_code"))));

}

From source file:com.google.mr4c.dataset.LogsDatasetBuilder.java

private DataFile makeFile(File file) {
    DataFileSource src = new URIDataFileSource(file.toURI(), file.getName());
    return new DataFile(src, "text/plain");
}

From source file:net.jakubholy.jeeutils.jsfelcheck.expressionfinder.impl.facelets.ValidatingFaceletsParserExecutor.java

public void execute() {
    validatingParser.registerTaglibs(findTaglibFiles());

    Collection<File> allViews = findViewFiles();
    for (File view : allViews) {
        try {//from  ww w . ja va2 s  .  com
            validatingParser.validateExpressionsInView(view.toURI().toURL(), toRootRelativePath(view));
        } catch (IOException e) {
            // Highly unlikely but let's not ignore it anyway
            throw new RuntimeException("Failed to access the view file " + view.getAbsolutePath(), e);
        }
    }
}

From source file:cz.cas.lib.proarc.common.config.Profiles.java

public Profiles(Configuration config, File configHome) {
    this.config = config;
    this.configHomeUri = configHome.toURI();
}

From source file:com.athena.peacock.common.core.util.SshExecUtil.java

/**
 * <pre>/* w ww. j a  v a 2 s.  c  o  m*/
 * 
 * </pre>
 * @param targetHost
 * @param command
 * @return
 * @throws IOException 
 */
public static String executeCommand(TargetHost targetHost, String command) throws IOException {
    Assert.notNull(targetHost, "targetHost cannot be null.");
    Assert.notNull(command, "command cannot be null.");

    File result = new File(SshExecUtil.class.getClassLoader().getResource(".").getFile(), "result.log");

    if (!command.startsWith("sudo")) {
        command = "sudo " + command;
    }

    logger.debug("[ssh exec] " + command);

    Project project = new Project();

    SSHExec exec = new SSHExec();
    exec.setProject(project);
    exec.setHost(targetHost.getHost());
    exec.setPort(targetHost.getPort());
    exec.setUsername(targetHost.getUsername());
    exec.setPassword(targetHost.getPassword());

    // to enable sudo like 'ssh -t' option
    exec.setUsePty(true);

    if (targetHost.getKeyfile() != null) {
        exec.setKeyfile(targetHost.getKeyfile());
    }

    exec.setTrust(targetHost.isTrust());
    exec.setVerbose(true);
    exec.setCommand(command);

    // command   ? ? 
    exec.setOutput(result);
    exec.setAppend(false);

    exec.execute();

    return IOUtils.toString(result.toURI());
}