List of usage examples for java.nio.file FileSystems getDefault
public static FileSystem getDefault()
From source file:com.groupdocs.ui.ViewerUtils.java
public static Path getProjectBaseDir() { Properties props = new Properties(); try {/* w w w . java 2 s . c o m*/ InputStream i = ViewerUtils.class.getResourceAsStream("/project.properties"); props.load(i); } catch (IOException x) { throw new RuntimeException(x); } return FileSystems.getDefault().getPath(props.getProperty("project.basedir")); }
From source file:eu.uqasar.web.upload.FileUploadUtil.java
private static Path getUserUploadFolder(User user) throws IOException { String userId = "default"; if (user != null) { userId = String.valueOf(user.getId()); }/*from w w w.j a va 2s. c o m*/ Path path = FileSystems.getDefault().getPath(getUploadFolderBasePath(), userId); if (!Files.exists(path)) { Files.createDirectories(path); } return path; }
From source file:cz.muni.fi.mir.services.FileServiceImpl.java
@Override public boolean canonicalizerExists(String revisionHash) { Path temp = FileSystems.getDefault().getPath(this.jarsFolder, revisionHash + ".jar"); return Files.exists(temp); }
From source file:eu.uqasar.web.upload.FileUploadUtil.java
public static Path getBaseUploadFolder() throws IOException { Path basePath = FileSystems.getDefault().getPath(getUploadFolderBasePath()); if (!Files.exists(basePath)) { Files.createDirectories(basePath); }//from ww w . ja v a 2 s . com return basePath; }
From source file:org.apache.cassandra.utils.HeapUtils.java
/** * Generates a HEAP dump in the directory specified by the <code>HeapDumpPath</code> JVM option * or in the <code>CASSANDRA_HOME</code> directory. */// w ww . j a v a 2s . co m public static void generateHeapDump() { Long processId = getProcessId(); if (processId == null) { logger.error("The process ID could not be retrieved. Skipping heap dump generation."); return; } String heapDumpPath = getHeapDumpPathOption(); if (heapDumpPath == null) { String cassandraHome = System.getenv("CASSANDRA_HOME"); if (cassandraHome == null) { return; } heapDumpPath = cassandraHome; } Path dumpPath = FileSystems.getDefault().getPath(heapDumpPath); if (Files.isDirectory(dumpPath)) { dumpPath = dumpPath.resolve("java_pid" + processId + ".hprof"); } String jmapPath = getJmapPath(); // The jmap file could not be found. In this case let's default to jmap in the hope that it is in the path. String jmapCommand = jmapPath == null ? "jmap" : jmapPath; String[] dumpCommands = new String[] { jmapCommand, "-dump:format=b,file=" + dumpPath, processId.toString() }; // Lets also log the Heap histogram String[] histoCommands = new String[] { jmapCommand, "-histo", processId.toString() }; try { logProcessOutput(Runtime.getRuntime().exec(dumpCommands)); logProcessOutput(Runtime.getRuntime().exec(histoCommands)); } catch (IOException e) { logger.error("The heap dump could not be generated due to the following error: ", e); } }
From source file:com.github.rwhogg.git_vcr.review.php.PhpmdReviewTool.java
@Override public List<String> getResults(File file) throws ReviewFailedException { // delete the cache first Path pathToCache = FileSystems.getDefault().getPath(System.getProperty("user.home"), ".pdepend"); try {//w w w . j av a 2s .co m FileUtils.deleteQuietly(pathToCache.toFile()); } catch (Exception e) { } List<Object> rules = configuration.getList("rules"); String commandTemplate = "\"%s\" text \"%s\""; List<String> results; try { StringBuffer ruleStringBuffer = new StringBuffer(); for (Object rule : rules) { ruleStringBuffer.append((String) rule + ","); } String ruleString = ruleStringBuffer.toString(); results = runProcess(String.format(commandTemplate, file.getAbsolutePath(), ruleString.substring(0, ruleString.length() - 1))); } catch (IOException e) { throw new ReviewFailedException(e.getLocalizedMessage(), this, file.getAbsolutePath()); } // first result is always an empty line if ((results != null) && (results.size() > 0)) { List<String> copy = new LinkedList<>(); copy.addAll(results); copy.remove(0); results = copy; } return results; }
From source file:com.groupdocs.ui.Utils.java
public static void loadLicense() { License l = new License(); if (Files.exists(FileSystems.getDefault().getPath(getProjectProperty("license.path")))) { l.setLicense(getProjectProperty("license.path")); if (!License.isValidLicense()) { throw new RuntimeException("Invalid license found."); }// w w w . j a v a 2 s .c o m } }
From source file:org.jamocha.classloading.Loader.java
/** * Recursively loads all class files in the specified directory. The name of the directory is to be split up into * the part specifying the path to the start of the package hierarchy and the part specifying which part of the * hierarchy is to be loaded. <br /> <b>Example:</b> loadClassesInDirectory("target/classes", * "org/jamocha/function/impls/predicates"); loads all class files within * "target/classes/org/jamocha/function/impls/predicates" * and the files found in that folder there have the package specification "org.jamocha.function.impls.predicates". * Class files in sub directories of the predicates folder have their package specification adjusted accordingly. * * @param pathToDir/*from w w w .j ava 2 s. co m*/ * the base path to the directory containing the package hierarchy (separator '/') * @param packageString * the path within the package hierarchy (separator '/') */ public static void loadClassesInDirectory(final String pathToDir, final String packageString) { log.debug("Loading classes in directory file:{}/{}", pathToDir, packageString); final Path basePath = FileSystems.getDefault().getPath(pathToDir); try (final Stream<Path> files = java.nio.file.Files .walk(FileSystems.getDefault().getPath(pathToDir, packageString))) { files.filter(file -> !file.toFile().isDirectory() && file.toString().endsWith(".class")) .forEach(file -> { final Path filePath = basePath.relativize(file); final String clazzName = filePathToClassName(filePath.toString()); log.debug("Loading class {}", clazzName); try { Class.forName(clazzName); } catch (final ClassNotFoundException ex) { log.catching(ex); } catch (final ExceptionInInitializerError ex) { log.catching(ex); } }); } catch (final IOException ex) { log.catching(ex); } }
From source file:org.cryptomator.frontend.webdav.mount.WindowsDriveLetters.java
public Set<Character> getOccupiedDriveLetters() { if (!SystemUtils.IS_OS_WINDOWS) { throw new UnsupportedOperationException("This method is only defined for Windows file systems"); }// ww w . ja v a 2 s . c o m Iterable<Path> rootDirs = FileSystems.getDefault().getRootDirectories(); return StreamSupport.stream(rootDirs.spliterator(), false).map(Path::toString).map(CharUtils::toChar) .map(Character::toUpperCase).collect(toSet()); }
From source file:cz.muni.fi.editor.commons.CommonsConfiguration.java
@Bean public FileSystemProvider fileSystemProvider() { FileSystemProviderImpl fsp = new FileSystemProviderImpl(); if (environment.acceptsProfiles("!test")) { fsp.setFileSystem(FileSystems.getDefault()); } else {// www . j a v a 2s . co m fsp.setFileSystem(Jimfs.newFileSystem(com.google.common.jimfs.Configuration.unix())); } return fsp; }