Example usage for java.nio.file FileSystems getDefault

List of usage examples for java.nio.file FileSystems getDefault

Introduction

In this page you can find the example usage for java.nio.file FileSystems getDefault.

Prototype

public static FileSystem getDefault() 

Source Link

Document

Returns the default FileSystem .

Usage

From source file:org.schimpf.util.Logger.java

/**
 * @author <FONT style='color:#55A; font-size:12px; font-weight:bold;'>Hermann D. Schimpf</FONT>
 * @author <B>SCHIMPF</B> - <FONT style="font-style:italic;">Sistemas de Informaci&oacute;n y Gesti&oacute;n</FONT>
 * @author <B>Schimpf.NET</B>
 * @version Aug 1, 2012 5:08:04 PM/*from  ww  w  .j a v  a 2  s . c  o m*/
 * @param clazz Clase que registra el logger
 * @param logFile Ruta al fichero log
 */
public Logger(final Class<? extends Object> clazz, final String logFile) {
    // almacenamos la clase
    this.clazz = clazz;
    // almacenamos el nombre
    this.name = this.getLogClass().getName().substring(this.getLogClass().getName().lastIndexOf(".") + 1);
    // verificamos si es una carpeta
    if (logFile != null && new File(logFile).exists() && new File(logFile).isDirectory())
        // el fichero log lo tomamos desde el nombre
        this.logFile = new File(logFile + FileSystems.getDefault().getSeparator() + this.name + ".log");
    else
        // almacenamos el fichero log
        this.logFile = new File(logFile != null ? logFile : this.name + ".log");
    // verificamos si se especifico el fichero log
    this.enableLogFile(logFile != null);
}

From source file:org.pentaho.ctools.cpf.repository.factory.ContentAccessFactory.java

private IRWAccess getPluginRepositoryOverlay(String basePath) {
    // implemented as a filesystem folder on foundry, as it is a storage area common to all users
    String storagePath = createStoragePath(PLUGIN_REPOS_NAMESPACE);
    return new FileSystemRWAccess(FileSystems.getDefault(), storagePath, basePath);
}

From source file:com.liferay.sync.engine.service.persistence.SyncFilePersistence.java

public void updateByParentFilePathName(String parentFilePathName, int state, int uiEvent) throws SQLException {

    UpdateBuilder<SyncFile, Long> updateBuilder = updateBuilder();

    updateBuilder.updateColumnValue("state", state);
    updateBuilder.updateColumnValue("uiEvent", uiEvent);

    Where<SyncFile, Long> where = updateBuilder.where();

    FileSystem fileSystem = FileSystems.getDefault();

    parentFilePathName = StringUtils.replace(parentFilePathName + fileSystem.getSeparator(), "\\", "\\\\");

    where.like("filePathName", new SelectArg(parentFilePathName + "%"));

    updateBuilder.update();/*from w  w  w.j  a  v a 2s  .c o  m*/
}

From source file:cpd3314.project.CPD3314ProjectTest.java

@Test
public void testFindOneWordAndOutput() throws Exception {
    System.out.println("main");
    String[] args = { "-find=lorem", "-o=lorem" };
    CPD3314Project.main(args);/*from  ww w .j  a v  a  2 s  . c o  m*/
    File expected = FileSystems.getDefault().getPath("testFiles", "findOne.xml").toFile();
    File result = new File("lorem.xml");
    assertTrue("Output File Doesn't Exist", result.exists());
    assertXMLFilesEqual(expected, result);
}

From source file:edu.vt.vbi.patric.cache.DataLandingGenerator.java

public boolean createCacheFileGenomicFeatures(String filePath) {
    boolean isSuccess = false;
    JSONObject jsonData = new JSONObject();
    JSONObject data;//ww  w. ja  v a 2s  .com

    // from WP
    // data
    data = read(baseURL + "/tab/dlp-genomicfeatures-data/?req=passphrase");
    if (data != null) {
        jsonData.put("data", data);
    }
    // popular genomes
    data = getPopularGenomesForGenomicFeature();
    if (data != null) {
        jsonData.put("popularGenomes", data);
    }
    // tools
    data = read(baseURL + "/tab/dlp-genomicfeatures-tools/?req=passphrase");
    if (data != null) {
        jsonData.put("tools", data);
    }
    // process
    data = read(baseURL + "/tab/dlp-genomicfeatures-process/?req=passphrase");
    if (data != null) {
        jsonData.put("process", data);
    }
    // download
    data = read(baseURL + "/tab/dlp-genomicfeatures-download/?req=passphrase");
    if (data != null) {
        jsonData.put("download", data);
    }

    // save jsonData to file
    try (PrintWriter jsonOut = new PrintWriter(
            Files.newBufferedWriter(FileSystems.getDefault().getPath(filePath), Charset.defaultCharset()));) {
        jsonData.writeJSONString(jsonOut);
        isSuccess = true;
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return isSuccess;
}

From source file:de.joinout.criztovyl.tools.file.Path.java

/**
 * @return this {@link Path} as a {@link java.nio.file.Path}.
 */
public java.nio.file.Path getNIOPath() {
    return FileSystems.getDefault().getPath(getPath());
}

From source file:cpd3314.project.CPD3314ProjectTest.java

@Test
public void testFindMultiWordsAndOutput() throws Exception {
    System.out.println("main");
    String[] args = { "-find=dolor sit amet", "-o=dolor" };
    CPD3314Project.main(args);//from  w w w.ja v a  2s .com
    File expected = FileSystems.getDefault().getPath("testFiles", "findMulti.xml").toFile();
    File result = new File("dolor.xml");
    assertTrue("Output File Doesn't Exist", result.exists());
    assertXMLFilesEqual(expected, result);
}

From source file:org.apache.coheigea.bigdata.knox.ranger.KnoxRangerTest.java

private void makeStormUIInvocation(int statusCode, String user, String password) throws IOException {
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }// w  w  w  .j a va2  s.co  m
    Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/cluster-configuration.json");

    stormServer.expect().method("GET").pathInfo("/api/v1/cluster/configuration").respond()
            .status(HttpStatus.SC_OK).content(IOUtils.toByteArray(path.toUri()))
            .contentType("application/json");

    given().auth().preemptive().basic(user, password).header("X-XSRF-Header", "jksdhfkhdsf")
            .header("Accept", "application/json").when()
            .get("http://localhost:" + gateway.getAddresses()[0].getPort() + "/gateway/cluster/storm"
                    + "/api/v1/cluster/configuration")
            .then().log().all().statusCode(statusCode);

}

From source file:us.colloquy.index.IndexHandler.java

public void getURIForAllLetters(Set<DocumentPointer> uriList, String letterDirectory, boolean useOnlyNumber) {
    ///Documents/Tolstoy/diaries

    Path pathToLetters = FileSystems.getDefault().getPath(letterDirectory);

    List<Path> results = new ArrayList<>();

    int maxDepth = 6;

    try (Stream<Path> stream = Files.find(pathToLetters, maxDepth, (path, attr) -> {
        return String.valueOf(path).endsWith(".ncx");
    })) {/*from w  w w . ja va  2  s. com*/

        stream.forEach(results::add);

        //            String joined = stream
        //                    .sorted()
        //                    .map(String::valueOf)
        //                    .collect(Collectors.joining("; "));
        //
        //            System.out.println("\nFound: " + joined);

    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("files: " + results.size());

    try {

        for (Path res : results) {
            Path parent = res.getParent();

            //                System.out.println("---------------------------------------------");
            //                System.out.println(parent.toString());
            //use jsoup to list all files that contain something useful
            Document doc = Jsoup.parse(res.toFile(), "UTF-8");

            String title = "";

            for (Element element : doc.getElementsByTag("docTitle")) {
                //Letter letter = new Letter();

                // StringBuilder content = new StringBuilder();

                for (Element child : element.children()) {
                    title = child.text();
                    // System.out.println("Title: " + title);
                }
            }

            for (Element element : doc.getElementsByTag("navPoint")) {
                //Letter letter = new Letter();

                // StringBuilder content = new StringBuilder();

                for (Element child : element.children()) {
                    String label = child.text();

                    if (StringUtils.isNotEmpty(label)) {
                        if (label.matches("?")) {
                            System.out.println("------------------");
                        }

                        String url = child.getElementsByTag("content").attr("src");

                        if (label.matches(".*\\d{1,3}.*[?--?]+.*") && StringUtils.isNotEmpty(url)) {
                            DocumentPointer documentPointer = new DocumentPointer(
                                    parent.toString() + File.separator + url.replaceAll("#.*", ""), title);

                            uriList.add(documentPointer);
                            //                                System.out.println("nav point: " + label + " src " + parent.toString()
                            //                                        + System.lineSeparator() + url.replaceAll("#.*",""));

                        } else if (label.matches(".*\\d{1,3}.*") && StringUtils.isNotEmpty(url)
                                && useOnlyNumber) {
                            DocumentPointer documentPointer = new DocumentPointer(
                                    parent.toString() + File.separator + url.replaceAll("#.*", ""), title);

                            uriList.add(documentPointer);
                            //                                System.out.println("nav point: " + label + " src " + parent.toString()
                            //                                        + System.lineSeparator() + url.replaceAll("#.*",""));

                        } else {
                            // System.out.println("nav point: " + label + " src " + child.getElementsByTag("content").attr("src"));
                        }

                    }
                }
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    //        System.out.println("Size: " + uriList.size());

    //        for (DocumentPointer pointer : uriList)
    //        {
    //            //parse and
    //            System.out.println(pointer.getSourse() + "\t" + pointer.getUri());
    //        }
}

From source file:com.liferay.sync.engine.service.SyncAccountService.java

public static SyncAccount setFilePathName(long syncAccountId, String targetFilePathName) {

    // Sync account

    SyncAccount syncAccount = fetchSyncAccount(syncAccountId);

    String sourceFilePathName = syncAccount.getFilePathName();

    syncAccount.setFilePathName(targetFilePathName);

    update(syncAccount);//from  w ww.  j  av a2  s. c  o  m

    // Sync file

    SyncFile syncFile = SyncFileService.fetchSyncFile(sourceFilePathName);

    syncFile.setFilePathName(targetFilePathName);

    SyncFileService.update(syncFile);

    // Sync files

    if (syncFile.isFolder()) {
        SyncFileService.renameSyncFiles(sourceFilePathName, targetFilePathName);
    }

    // Sync sites

    FileSystem fileSystem = FileSystems.getDefault();

    List<SyncSite> syncSites = SyncSiteService.findSyncSites(syncAccountId);

    for (SyncSite syncSite : syncSites) {
        String syncSiteFilePathName = syncSite.getFilePathName();

        syncSiteFilePathName = StringUtils.replaceOnce(syncSiteFilePathName,
                sourceFilePathName + fileSystem.getSeparator(), targetFilePathName + fileSystem.getSeparator());

        syncSite.setFilePathName(syncSiteFilePathName);

        SyncSiteService.update(syncSite);
    }

    return syncAccount;
}