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:au.edu.uq.cmm.paul.queue.AbstractQueueFileManager.java

@Override
public final File renameGrabbedDatafile(File file) throws QueueFileException {
    String extension = FilenameUtils.getExtension(file.toString());
    if (!extension.isEmpty()) {
        extension = "." + extension;
    }/* www  . j a  va2  s.c o  m*/
    for (int i = 0; i < RETRY; i++) {
        File newFile = generateUniqueFile(extension, false);
        if (!file.renameTo(newFile)) {
            if (!Files.exists(newFile.toPath(), LinkOption.NOFOLLOW_LINKS)) {
                throw new QueueFileException("Unable to rename file or symlink " + file + " to " + newFile);
            }
        } else {
            return newFile;
        }
    }
    throw new QueueFileException(RETRY + " attempts to rename file / symlink failed!");
}

From source file:com.github.jknack.handlebars.io.FileTemplateLoader.java

/**
 * Creates a new {@link FileTemplateLoader}.
 *
 * @param basedir The base directory. Required.
 * @param suffix The view suffix. Required.
 *//*from  w w  w.  ja  va  2  s.c  om*/
public FileTemplateLoader(final File basedir, final String suffix) {
    notNull(basedir, "The base dir is required.");
    isTrue(basedir.exists(), "File not found: %s", basedir);
    isTrue(basedir.isDirectory(), "A directory is required: %s", basedir);
    setPrefix(basedir.toString());
    setSuffix(suffix);
}

From source file:tools.descartes.bungee.viewer.MappingView.java

/**
 * Shows the given selection in this view.
 */// w  ww  .  j  av a 2  s .  c  om
public void showSelection(IWorkbenchPart sourcepart, ISelection selection) {
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof IResource) {
            File file = ((IResource) element).getLocation().toFile();
            boolean isMappingFunction = IntensityDemandMapping.isMappingFunction(file);
            if (isMappingFunction) {
                setContentDescription(file.toString());
                if (chartComposite != null) {
                    chartComposite.dispose();
                }
                IntensityDemandMapping mapping = IntensityDemandMapping.read(file);
                final JFreeChart chart = ChartGenerator.mappingChart(mapping);
                chartComposite = new ChartComposite(parent, SWT.NONE, chart, false);
                // repaint
                parent.layout(true);
            }
        }
    }
}

From source file:com.wavemaker.StudioInstallService.java

public void DownloadPackages() throws Exception {
    File webapproot = new File(RuntimeAccess.getInstance().getSession().getServletContext().getRealPath(""));

    URL url = new URL("https://raw.github.com/cloudjee/WaveMaker-LGPL-Resources/6.6/repo.zip");
    URLConnection urlC = url.openConnection();
    // Copy resource to local file, use remote file
    // if no local file name specified
    InputStream is = url.openStream();

    File outputFile = new File(webapproot, "repo.zip");
    System.out.println("WRITE TO " + outputFile.toString());
    FileOutputStream fos = new FileOutputStream(outputFile);
    int oneChar;/*from  w  w  w  .j a  v  a  2s  . c  om*/
    while ((oneChar = is.read()) != -1) {
        fos.write(oneChar);
    }
    is.close();
    fos.close();
    System.out.println("WROTE TO " + outputFile.getAbsolutePath());
    if (!outputFile.exists())
        throw new IOException("Insufficient permissions to save zip file");
    File zipFolder = unzipFile(outputFile);
    moveFiles(zipFolder, outputFile);
}

From source file:EmbeddedFlume.EmbeddedFlume.TestFlumeEmbeddedAgentnew.java

public void run(String args[]) throws Exception {

    Map<String, String> config = new HashMap<String, String>();
    parseHostsAndPort(config);/*from w  w w.  j  av a2 s.  c o  m*/

    File dcDir = Files.createTempDir();
    dcDir.deleteOnExit();
    config.put("source.type", "embedded");
    config.put("channel.type", "memory");
    config.put("channel.capacity", "100000");
    config.put("channel.dataDirs", dcDir.toString() + "/data");
    config.put("channel.checkpointDir", dcDir.toString() + "/checkpoint");
    agent.configure(config);
    agent.start();
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        public void run() {
            agent.stop();
        }
    }));
}

From source file:cz.cas.lib.proarc.common.process.GenericExternalProcessTest.java

/** onExit is an experimental feature .*/
@Test/*from  w  w  w.  j  a v a2  s. c om*/
public void testIMConvertOnExit() throws Exception {
    String imageMagicExec = "/usr/bin/convert";
    Assume.assumeTrue(new File(imageMagicExec).exists());
    File confFile = temp.newFile("props.cfg");
    File root = temp.getRoot();
    URL pdfaResource = TiffImporterTest.class.getResource("pdfa_test.pdf");
    File pdfa = new File(root, "pdfa_test.pdf");
    FileUtils.copyURLToFile(pdfaResource, pdfa);
    FileUtils.writeLines(confFile,
            Arrays.asList("input.file.name=RESOLVED", "exec=" + imageMagicExec, "arg=-thumbnail", "arg=120x128",
                    "arg=$${input.file}[0]", "arg=-flatten", "arg=$${input.folder}/$${input.file.name}.jpg",
                    "result.file=$${input.folder}/$${input.file.name}.jpg", "onExits=0",
                    "onExit.0.param.output.file=$${input.folder}/$${input.file.name}.jpg", "id=test"));
    PropertiesConfiguration conf = new PropertiesConfiguration(confFile);
    GenericExternalProcess gep = new GenericExternalProcess(conf);
    gep.addInputFile(pdfa);
    gep.run();
    //        System.out.printf("#exit: %s, out: %s\nresults: %s\n",
    //                gep.getExitCode(), gep.getFullOutput(), gep.getResultParameters());
    assertEquals("exit code", 0, gep.getExitCode());
    File output = gep.getOutputFile();
    assertNotNull(output);
    assertTrue(output.toString(), output.exists());
    assertTrue("Not JPEG", InputUtils.isJpeg(output));
}

From source file:klapersuite.prismanalysis.linux.PrismRunner.java

public Process launch(File pmFile, File pctlFile, int resultDecimalDigitsPrecision) throws IOException {
    if (!pmFile.canRead())
        throw new IOException("pmFile is not accessible (" + pmFile.toString() + ")");
    if (!pctlFile.canRead())
        throw new IOException("pctlFile is not accessible (" + pctlFile.toString() + ")");
    Process prismProcess = launchPrism(new String[] { "-cuddmaxmem",
            String.valueOf(Math.max(IN_KB_512MB, new SystemMemory().availableRam(IN_KB_512MB))), "-maxiters",
            "200000", "-e", "1e-" + resultDecimalDigitsPrecision, pmFile.toString(), pctlFile.toString() });
    if (prismProcess == null)
        throw new IOException("Prism solver doesn't run properly");
    if (exitValueAfterTermination(prismProcess) != 0)
        throw new IOException("Prism solver doesn't work properly");
    return prismProcess;
}

From source file:com.thoughtworks.go.config.materials.mercurial.HgMaterialUpdaterTest.java

private void updateTo(HgMaterial material, RevisionContext revisionContext, JobResult expectedResult,
        File workingFolder) {
    BuildSession buildSession = newBuildSession();
    JobResult result = buildSession/*from w w w  .ja  v a2  s .c  om*/
            .build(new HgMaterialUpdater(material).updateTo(workingFolder.toString(), revisionContext));
    assertThat(buildInfo(), result, is(expectedResult));
}

From source file:dk.statsbiblioteket.util.qa.PackageScanner.java

/**
 * Scan QA annotations for a file or recursively through a directory.
 *
 * @param source The source./*ww  w  . ja v  a 2 s.  c om*/
 * @throws IOException If there is an error reading a class file.
 */
protected final void scan(String source) throws IOException {
    if (source == null) {
        throw new NullPointerException("Source argument is null");
    }
    File sourceFile = new File(baseSource, source);

    if (!sourceFile.exists()) {
        throw new FileNotFoundException(sourceFile.toString());
    }

    if (sourceFile.isFile()) {
        scanFile(source);
    } else {
        scanDirectory(source);
    }
}

From source file:com.symbian.driver.plugins.comms.stat.StatTransfer.java

public boolean mkdir(File aSymbianDir) {
    LOGGER.info("Creating folder " + aSymbianDir.toString());
    JStatResult lResult = null;//from   w w w  .  j a  va  2 s. c om
    String lDir = aSymbianDir.toString().replaceAll("/", "\\");
    try {
        lResult = iStatProxy.getStat().createFolder(lDir);

        if (lResult.getReturnedValue() == 13) {
            return true;
        }
    } catch (TimeLimitExceededException lTimeLimitExceededException) {
        LOGGER.log(Level.SEVERE, "Time limit exeeded", lTimeLimitExceededException);
    } catch (JStatException lJStatException) {
        LOGGER.log(Level.SEVERE, "STAT exception", lJStatException);
    }
    LOGGER.log(Level.SEVERE,
            "Failed to create folder " + aSymbianDir + ((lResult != null) ? " : " + lResult.toString() : ""));
    return false;
}