Example usage for java.io File toString

List of usage examples for java.io File toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns the pathname string of this abstract pathname.

Usage

From source file:io.stallion.templating.JinjaResourceLocator.java

private String getStringDirect(String s, Charset charset) throws IOException {

    if (s.contains("jar:") || s.contains("file:/")) {
        URL url = new URL(s);
        return ResourceHelpers.loadResourceFromUrl(url);
    } else if (s.contains(":")) {
        String[] parts = s.split(":", 2);
        String pluginName = parts[0];
        String pathName = parts[1];
        if (pathName.startsWith("/")) {
            pathName = pathName.substring(1);
        }//from   www. ja  v  a  2  s.  c  o  m
        String resourcePath = "/templates/" + pathName;
        return ResourceHelpers.loadAssetResource(pluginName, resourcePath);
    }
    if (s.startsWith("/")) {
        s = s.substring(1);
    }
    String path = targetDirectory + s;
    File file = new File(path);
    Log.finer("Load jinja template from path: {0}", file.toString());
    if (!file.exists() || !file.isFile()) {
        Log.fine("Jinja template does not exist: {0}", file.toString());
        return null;
    }

    String source = FileUtils.readFileToString(new File(path), charset.name());
    return source;

}

From source file:com.CodeSeance.JSeance.CodeGenXML.DependencyTracking.DependencyManager.java

public void clearTemplateDependencies(File templateFile) {
    String key = templateFile.toString();
    if (!templateDependencies.containsKey(key)) {
        templateDependencies.remove(key);
    }//from   w w w  .  j a  v a 2 s . c  o m
}

From source file:com.CodeSeance.JSeance.CodeGenXML.DependencyTracking.DependencyManager.java

public TemplateDependencies getTemplateDependencies(File templateFile) {
    String key = templateFile.toString();
    if (!templateDependencies.containsKey(key)) {
        templateDependencies.put(key, new TemplateDependencies(templateFile));
    }//from   ww w.  j ava2 s.c  o  m
    return templateDependencies.get(key);
}

From source file:de.fau.osr.util.VisibleFilesTraverser.java

protected void handleFile(File file, int depth, Collection results) throws IOException {
    // Using unix-style file paths.
    String filename = file.toString().replaceAll(Matcher.quoteReplacement("\\"), "/");
    for (String eachIgnore : ignoreList)
        if (filename.contains(eachIgnore))
            return;
    results.add(startDirectory.relativize(file.toPath()));
}

From source file:eu.scape_project.pc.droid.cli.DroidCli.java

private synchronized void processFile(File path) throws FileNotFoundException, IOException {
    if (dihj != null) {
        String puid = dihj.identify(path.toString());
        counter++;//from  w  w w.  j  a v a  2s.c om
        System.out.println(counter + "\t" + path.toString() + "\t" + puid);
    } else {
        logger.error("Droid identifier not available");
    }

}

From source file:com.photon.phresco.framework.impl.DocumentGeneratorImpl.java

public void deleteOldDocument(File filePath, String oldAppDirName) throws PhrescoException {
    String pdfFilePath = filePath.toString() + File.separator + "docs" + File.separator + oldAppDirName
            + "_doc.pdf";
    FileUtil.delete(new File(pdfFilePath));
}

From source file:gool.executor.objc.ObjcCompiler.java

@Override
public File compileToExecutable(List<File> files, File mainFile, List<File> classPath, List<String> args)
        throws FileNotFoundException {

    List<String> params = new ArrayList<String>();
    if (mainFile == null) {
        mainFile = files.get(0);/*from w w w .  j ava  2  s .com*/
    }

    logger.info("--->" + mainFile);
    String execFileName = mainFile.getName().replace(".m", "");
    params.addAll(Arrays.asList(Settings.get("objc_compiler_cmd")));
    for (File file : files) {
        if (!params.contains(file.toString()))
            params.add(file.toString());
    }
    // the -std=gnu99 option is used to allow initial declarations in 'for'
    // loop
    params.addAll(Arrays.asList("-std=gnu99", "-lgnustep-base", "-o", execFileName));

    /*
     * Add the needed dependencies to be able to compile programs.
     */
    if (classPath != null) {
        for (File dependency : classPath) {
            params.add(dependency.getAbsolutePath());
        }
    }

    // The command getObjcFlags returns the flags that have to be added
    // to the ObjC compilation command
    List<String> getObjcFlags = new ArrayList<String>();
    getObjcFlags.addAll(Arrays.asList("gnustep-config", "--objc-flags"));
    String flags = Command.exec(getOutputDir(), getObjcFlags);

    // Here, we add each flag to the command line parameters
    while (flags.contains(" ")) {
        String flag = flags.substring(0, flags.indexOf(" "));
        params.add(flag);
        flags = flags.replace(flag + " ", "");
    }
    if (!flags.isEmpty())
        params.add(flags.substring(0, flags.length() - 1));

    Command.exec(getOutputDir(), params);
    return new File(getOutputDir(), execFileName);
}

From source file:ezbake.persist.FilePersist.java

private List<String> getFiles(String path, String root, List<String> data) {
    File file = new File(path);
    File[] files = file.listFiles();
    if (file.exists()) {
        data.add(path.replaceFirst(joinPath(root, ""), ""));
    }//w  w  w.  ja va 2s .  c  om
    if (files != null) {
        for (File f : files) {
            getFiles(f.toString(), root, data);
        }
    }
    return data;
}

From source file:fr.efl.chaine.xslt.GauloisListenerTest.java

@Test
public void listenerStart() throws Exception {
    GauloisPipe piper = new GauloisPipe(configFactory);
    ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(),
            "./src/test/resources/listener/start.xml");
    Config config = cu.buildConfig(emptyInputParams);
    config.setLogFileSize(true);/*  www  .java2s.c  om*/
    config.verify();
    assertEquals("Port escape does not work", 8123, config.getSources().getListener().getPort());
    assertEquals("STOP keyword escape does not work", "ARRETE",
            config.getSources().getListener().getStopKeyword());
    piper.setConfig(config);
    piper.setInstanceName("LISTENER_1");
    piper.launch();
    DefaultHttpClient httpClient = new DefaultHttpClient();
    File userDir = new File(System.getProperty("user.dir"));
    File source = new File(userDir, "src/test/resources/source.xml");
    HttpPut put = new HttpPut("http://localhost:8123/?url="
            + URLEncoder.encode(source.toURI().toURL().toExternalForm(), "UTF-8"));
    HttpResponse response = httpClient.execute(put);
    System.out.println(response.getStatusLine().toString());
    assertEquals(200, response.getStatusLine().getStatusCode());
    put.releaseConnection();
    // the same, with accents
    source = new File(userDir, "src/test/resources/source_avec_accents.xml");
    put = new HttpPut("http://localhost:8123/?url="
            + URLEncoder.encode(source.toURI().toURL().toExternalForm(), "UTF-8"));
    response = httpClient.execute(put);
    System.out.println(response.getStatusLine().toString());
    assertEquals(200, response.getStatusLine().getStatusCode());
    put.releaseConnection();

    // we must let GauloisPipe process submitted file, because JUnit closes since the tested method returns.
    Thread.sleep(1000);
    File outputDir = new File("target/generated-test-files");
    File target = new File(outputDir, "source-listen1.xml");
    assertTrue("File " + target.toString() + " does not exists", target.exists());
    HttpDelete delete = new HttpDelete("http://localhost:8123/?keyword=ARRETE");
    response = httpClient.execute(delete);
    System.out.println(response.getStatusLine().toString());
    assertEquals(200, response.getStatusLine().getStatusCode());
    delete.releaseConnection();
    File appendee = new File(outputDir, "listener-appendee.txt");
    assertTrue(appendee.getAbsolutePath() + " does not exists.", appendee.exists());
    String previousLine = null;
    try (BufferedReader br = new BufferedReader(new FileReader(appendee))) {
        String currentLine = br.readLine();
        while (currentLine != null) {
            previousLine = currentLine;
            currentLine = br.readLine();
        }
    }
    assertEquals(appendee.getAbsolutePath() + " does not ends with \"EOF\"", "EOF", previousLine);
}

From source file:com.blackducksoftware.integration.hub.detect.detector.yarn.YarnLockDetector.java

@Override
public DetectorResult extractable() throws DetectorException {
    final File yarn = cacheableExecutableFinder.getExecutable(CacheableExecutableType.YARN);
    if (yarn != null) {
        yarnExe = yarn.toString();
    }/*from w  ww. j  a v  a 2  s .  c  o m*/

    if (StringUtils.isBlank(yarnExe)) {
        return new ExecutableNotFoundDetectorResult("yarn");
    }

    return new PassedDetectorResult();
}