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.osate.atsv.integration.preparser.EngineConfigGenerator.java

private void setPermissions() {
    Set<PosixFilePermission> perms = new HashSet<>();
    perms.add(PosixFilePermission.OWNER_READ);
    perms.add(PosixFilePermission.OWNER_WRITE); // Required to allow overwriting on subsequent runs
    perms.add(PosixFilePermission.OWNER_EXECUTE);

    java.nio.file.Path parseJarPath = FileSystems.getDefault().getPath(targetDirStr + "parser.jar");
    java.nio.file.Path connectJarPath = FileSystems.getDefault().getPath(targetDirStr + "connector.jar");
    java.nio.file.Path runScriptPath = FileSystems.getDefault()
            .getPath(targetDirStr + (SystemUtils.IS_OS_WINDOWS ? "run.bat" : "run.sh"));

    try {//from  ww w. j  a v a 2  s . co m
        java.nio.file.Files.setPosixFilePermissions(parseJarPath, perms);
        java.nio.file.Files.setPosixFilePermissions(connectJarPath, perms);
        java.nio.file.Files.setPosixFilePermissions(runScriptPath, perms);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.openecomp.sdc.ci.tests.utils.rest.ImportRestUtils.java

private static File getGroupTypeZipFile(String elementName) throws IOException {
    Config config = Utils.getConfig();/*  w  w  w.ja  v a  2 s.c  o m*/
    String sourceDir = config.getImportResourceTestsConfigDir();
    sourceDir += File.separator + ".." + File.separator + "importTypesTest" + File.separator;
    java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir + File.separator + elementName,
            elementName + ".zip");
    return filePath.toFile();
}

From source file:com.liferay.sync.engine.SyncSystemTest.java

protected String getString(JsonNode jsonNode, String key, String defaultValue) {

    JsonNode childJsonNode = jsonNode.get(key);

    if (childJsonNode == null) {
        return defaultValue;
    }/*from w  w w.  j av  a2  s . c  o  m*/

    FileSystem fileSystem = FileSystems.getDefault();

    String value = childJsonNode.textValue();

    return value.replace("/", fileSystem.getSeparator());
}

From source file:com.htmlhifive.visualeditor.persister.LocalFileContentsPersister.java

/**
 * ??()?(Path)????.//from   ww  w  .j  a va2 s  . co  m
 * 
 * @param filename ??
 * @return path
 * @throws BadContentException
 */
private Path generateFileObj(String filename) throws BadContentException {
    if (isValidFileName(filename)) {
        for (Map.Entry<String, Path> e : customUrlPathMap.entrySet()) {
            if (filename.startsWith(e.getKey() + "/")) {
                return FileSystems.getDefault().getPath(e.getValue().toAbsolutePath().toString(),
                        filename.substring(e.getKey().length()));
            }
        }
    }
    return FileSystems.getDefault().getPath(defaultDir.toAbsolutePath().toString(), filename);
}

From source file:org.polago.deployconf.DeployConfRunner.java

/**
 * Gets the Path to use for storing the DeploymentConfig.
 * <p>//from  w  w  w.  j ava2 s.  c om
 * Unless an explicit deployment config File is set, the File is created in the configured repository and based on
 * the config name. If no repository is set, the current working directory is used.
 *
 * @param name the DeploymentConfig name to use
 * @return the Path to the DeploymentConfig
 */
public Path getDeploymentConfigPath(String name) {
    Path result = deploymentConfigFile;
    String dir = getRepositoryDirectory();
    if (dir == null) {
        dir = "";
    }
    if (deploymentConfigFile != null) {
        result = deploymentConfigFile;
    } else {
        FileSystem fs = FileSystems.getDefault();
        if (name != null) {
            result = fs.getPath(dir, name + "-" + DEPLOYMENT_CONFIG_SUFFIX);
        } else {
            result = fs.getPath(dir, DEPLOYMENT_CONFIG_SUFFIX);
        }
    }

    return result;
}

From source file:de.cebitec.readXplorer.differentialExpression.plot.DeSeq2GraphicsTopComponent.java

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
    ReadXplorerFileChooser fc = new ReadXplorerFileChooser(new String[] { "svg" }, "svg") {
        private static final long serialVersionUID = 1L;

        @Override//w  ww  .  j  av a  2s . co  m
        public void save(String fileLocation) {
            ProgressHandle progressHandle = ProgressHandleFactory
                    .createHandle("Save plot to svg file: " + fileLocation);
            Path to = FileSystems.getDefault().getPath(fileLocation, "");
            DeSeq2AnalysisHandler.Plot selectedPlot = (DeSeq2AnalysisHandler.Plot) plotType.getSelectedItem();
            Path from = currentlyDisplayed.toPath();
            try {
                Path outputFile = Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
                messages.setText("SVG image saved to " + outputFile.toString());
            } catch (IOException ex) {
                Date currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
                Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "{0}: " + ex.getMessage(),
                        currentTimestamp);
                JOptionPane.showMessageDialog(null, ex.getMessage(), "Could not write to file.",
                        JOptionPane.WARNING_MESSAGE);
            } finally {
                progressHandle.switchToDeterminate(100);
                progressHandle.finish();
            }

        }

        @Override
        public void open(String fileLocation) {
        }
    };
    fc.openFileChooser(ReadXplorerFileChooser.SAVE_DIALOG);
}

From source file:io.github.dsheirer.gui.SDRTrunk.java

/**
 * Gets (or creates) the SDRTRunk application home directory.
 *
 * Note: the user can change this setting to allow log files and other
 * files to reside elsewhere on the file system.
 *///from ww w  . j  a  va  2  s  .  co m
private Path getHomePath() {
    Path homePath = FileSystems.getDefault().getPath(System.getProperty("user.home"), "SDRTrunk");

    if (!Files.exists(homePath)) {
        try {
            Files.createDirectory(homePath);

            mLog.info("SDRTrunk - created application home directory [" + homePath.toString() + "]");
        } catch (Exception e) {
            homePath = null;

            mLog.error("SDRTrunk: exception while creating SDRTrunk home "
                    + "directory in the user's home directory", e);
        }
    }

    return homePath;
}

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 6:13:53 PM/*from  w w  w .  ja v a  2  s. com*/
 * @param name Nombre para el logger
 * @param logFile Ruta al fichero log
 */
public Logger(final String name, final String logFile) {
    // generamos una ruta
    final Throwable caller = new Throwable();
    // clase temporal
    Class<?> tempClass = null;
    // recorremos la ruta
    for (final StackTraceElement trace : caller.getStackTrace())
        try {
            // obtenemos el nombre de la clase
            final Class<?> callerClass = Class.forName(trace.getClassName());
            // verificamos si no es la clase Logger
            if (!callerClass.equals(this.getClass()))
                // almacenamos la clase
                tempClass = callerClass;
        } catch (final ClassNotFoundException ignored) {
        }
    // almacenamos la clase
    this.clazz = tempClass;
    // almacenamos la clase
    this.name = name;
    // 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:edu.vt.vbi.patric.cache.DataLandingGenerator.java

public boolean createCacheFileTranscriptomics(String filePath) {
    boolean isSuccess = false;
    JSONObject jsonData = new JSONObject();
    JSONObject data;//from   ww  w.  ja  va2  s . c om

    // from WP
    // data
    data = read(baseURL + "/tab/dlp-transcriptomics-data/?req=passphrase");
    if (data != null) {
        jsonData.put("data", data);
    }
    // tools
    data = read(baseURL + "/tab/dlp-transcriptomics-tools/?req=passphrase");
    if (data != null) {
        jsonData.put("tools", data);
    }
    // process
    data = read(baseURL + "/tab/dlp-transcriptomics-process/?req=passphrase");
    if (data != null) {
        jsonData.put("process", data);
    }
    // download
    data = read(baseURL + "/tab/dlp-transcriptomics-download/?req=passphrase");
    if (data != null) {
        jsonData.put("download", data);
    }
    // topSpecies
    data = getTopSpeciesForTranscriptomics();
    if (data != null) {
        jsonData.put("topSpecies", data);
    }
    // featuredExperiment
    data = getFeaturedExperimentForTranscriptomics();
    if (data != null) {
        jsonData.put("featuredExperiment", data);
    }
    // popularGenomes
    data = getPopularGenomesForTranscriptomics();
    if (data != null) {
        jsonData.put("popularGenomes", 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:org.osate.atsv.integration.preparser.EngineConfigGenerator.java

private void copyJars() {
    Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
    Path srcParsePath = new Path("src/main/resources/parser.jar");
    java.nio.file.Path dstParsePath = FileSystems.getDefault().getPath(targetDirStr + "parser.jar");
    Path srcConnectPath = new Path("src/main/resources/connector.jar");
    java.nio.file.Path dstConnectPath = FileSystems.getDefault().getPath(targetDirStr + "connector.jar");
    try (InputStream parseIS = FileLocator.openStream(bundle, srcParsePath, false);
            InputStream connectIS = FileLocator.openStream(bundle, srcConnectPath, false)) {
        if (java.nio.file.Files.exists(dstParsePath)) {
            java.nio.file.Files.delete(dstParsePath);
        }/*from www . j  a  v  a 2s.  co  m*/
        if (java.nio.file.Files.exists(dstConnectPath)) {
            java.nio.file.Files.delete(dstConnectPath);
        }
        java.nio.file.Files.copy(parseIS, dstParsePath);
        java.nio.file.Files.copy(connectIS, dstConnectPath);
    } catch (IOException e) {
        e.printStackTrace();
    }
}