Example usage for java.io File toPath

List of usage examples for java.io File toPath

Introduction

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

Prototype

public Path toPath() 

Source Link

Document

Returns a Path java.nio.file.Path object constructed from this abstract path.

Usage

From source file:com.thoughtworks.go.helper.SvnRemoteRepository.java

public void addUser(String username, String password) throws Exception {
    enableAuthentication();/* w  w  w  .j ava 2  s.  c  o m*/
    File passwdFile = new File(repo.projectRepositoryRoot(), "conf/passwd");
    String passwd = String.join(FileUtil.lineSeparator(), Files.readAllLines(passwdFile.toPath()));
    if (!(passwd.contains("\n[users]\n"))) {
        passwd = passwd + "\n[users]\n";
    }
    passwd = passwd + String.format("\n%s = %s\n", username, password);
    FileUtils.writeStringToFile(passwdFile, passwd, UTF_8);
}

From source file:br.com.softplan.jsversioning.process.WebFilesProcessor.java

public WebFilesProcessor(File webFilesDirectory, File webAppOutputDirectory, Log log) {
    this.webFilesDirectory = webFilesDirectory.toPath();
    this.webAppOutputDirectory = webAppOutputDirectory.toPath();
    this.log = log;
}

From source file:com.hurence.logisland.processor.CsvLoaderTest.java

@Test
public void CsvLoaderTest() throws IOException {
    File f = new File(RESOURCES_DIRECTORY);

    for (File file : FileUtils.listFiles(f, new SuffixFileFilter(".csv"), TrueFileFilter.INSTANCE)) {
        BufferedReader reader = Files.newBufferedReader(file.toPath(), ENCODING);
        List<Record> records = TimeSeriesCsvLoader.load(reader, true, inputDateFormat);

        Assert.assertTrue(!records.isEmpty());
        //Assert.assertTrue("should be 4032, was : " + events.size(), events.size() == 4032);

        for (Record record : records) {
            Assert.assertTrue("should be sensors, was " + record.getType(), record.getType().equals("sensors"));
            Assert.assertTrue("should be 5, was " + record.getFieldsEntrySet().size(),
                    record.getFieldsEntrySet().size() == 5);
            Assert.assertTrue(record.getAllFieldNames().contains("timestamp"));
            if (!record.getAllFieldNames().contains("value"))
                System.out.println("stop");
            Assert.assertTrue(record.getAllFieldNames().contains("value"));

            Assert.assertTrue(record.getField("timestamp").getRawValue() instanceof Long);
            Assert.assertTrue(record.getField("value").getRawValue() instanceof Double);
        }/*ww w  .  ja  v a2s  .  c  om*/
    }
}

From source file:sample.fa.ScriptRunnerApplication.java

void loadScript(File f) {
    try {// w  ww.jav a  2 s.  co m
        scriptContents.setText(String.join("\n", Files.readAllLines(f.toPath())));

        String name = f.getName();
        int lastDot = name.lastIndexOf('.');
        if (lastDot >= 0) {
            String extension = name.substring(lastDot + 1);
            for (int i = 0; i < languagesModel.getSize(); i++) {
                ScriptEngine se = languagesModel.getElementAt(i);
                if (se.getFactory().getExtensions().indexOf(extension) >= 0) {
                    languagesModel.setSelectedItem(se);
                    break;
                }
            }
        }
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(scriptContents, ex.getMessage(), "Error Loading Script",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:sample.fa.ScriptRunnerApplication.java

private void saveScript(ActionEvent ae) {
    JFileChooser jfc = new JFileChooser();
    jfc.showOpenDialog(scriptContents);//from w  w w  .  java2 s.c  o m
    File f = jfc.getSelectedFile();
    if (f != null) {
        try {
            Files.write(f.toPath(), scriptContents.getText().getBytes());
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(scriptContents, ex.getMessage(), "Error Saving Script",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

}

From source file:org.bonitasoft.web.designer.i18n.LanguagePackBuilderTest.java

@Test
public void should_build_all_language_pack_under_provided_directory() throws Exception {
    File frFile = folder.newFile("fr.po");
    folder.newFolder("i18n");
    File enFile = folder.newFile("i18n/en.po");
    write(frFile.toPath(), aSimplePoFile());
    write(enFile.toPath(), aSimplePoFile());

    builder.start(folder.getRoot().toPath());

    assertThat(resolveJson(frFile).exists()).isTrue();
    assertThat(resolveJson(enFile).exists()).isTrue();
}

From source file:com.liferay.ide.gradle.core.GradleProjectBuilder.java

public IStatus initBundle(IProject project, String bundleUrl, IProgressMonitor monitor) throws CoreException {
    String bundleUrlProperty = "\n\n" + LiferayWorkspaceUtil.LIFERAY_WORKSPACE_BUNDLE_URL + "=" + bundleUrl;

    IPath gradlePropertiesLocation = project.getFile("gradle.properties").getLocation();

    File gradlePropertiesFile = gradlePropertiesLocation.toFile();

    try {//from   ww  w . j  a  v a 2s. c om
        Files.write(gradlePropertiesFile.toPath(), bundleUrlProperty.getBytes(), StandardOpenOption.APPEND);
    } catch (IOException ioe) {
        GradleCore.logError("Error append bundle url property", ioe);
    }

    _runGradleTask("initBundle", monitor);

    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);

    return Status.OK_STATUS;
}

From source file:com.netflix.genie.core.services.impl.FileSystemAttachmentService.java

private void createAttachmentDirectory(final String attachmentsDirectory) {
    String attachmentsDirectoryPath = attachmentsDirectory;
    if (!attachmentsDirectoryPath.endsWith(File.separator)) {
        attachmentsDirectoryPath = attachmentsDirectory + File.separator;
    }//from w  ww . java 2  s . co m
    try {
        final File dir = new File(new URI(attachmentsDirectoryPath));
        if (!dir.exists()) {
            Files.createDirectories(dir.toPath());
        }
        this.attachmentDirectory = dir;
    } catch (IOException | URISyntaxException e) {
        throw new IllegalArgumentException(
                "Failed to create attachments directory " + attachmentsDirectoryPath);
    }
}

From source file:com.netflix.genie.web.services.impl.FileSystemAttachmentService.java

private void createAttachmentDirectory(final String attachmentsDirectory) {
    String attachmentsDirectoryPath = attachmentsDirectory;
    if (!attachmentsDirectoryPath.endsWith(File.separator)) {
        attachmentsDirectoryPath = attachmentsDirectory + File.separator;
    }// w w w . jav a2  s  .co  m
    try {
        final File dir = new File(new URI(attachmentsDirectoryPath));
        if (!dir.exists()) {
            Files.createDirectories(dir.toPath());
        }
        this.attachmentDirectory = dir;
    } catch (IOException | URISyntaxException e) {
        throw new IllegalArgumentException("Failed to create attachments directory " + attachmentsDirectoryPath,
                e);
    }
}

From source file:algorithm.F5Steganography.java

private String getCarrier(File carrierFile) {
    return "" + carrierFile.toPath();
}