/** * This implementation returns the name of the file. * @see java.nio.file.Path#getFileName() */ @Override public String getFilename() { return this.path.getFileName().toString(); }
CannotWriteException( Path file ) { super( format( "Could not write to: %s", file.toAbsolutePath().toString() ) ); } }
private static String unixifyPath(String path) { return Paths.get(path).toAbsolutePath().toString().replace("\\", "/"); }
private Path tempPath() { Path parent = path.getParent(); File file = parent.toFile(); if (!file.exists()) { file.mkdirs(); } return parent.resolve(path.getFileName().toString() + '.' + tempSuffix()); }
static String resolveLocalRepoPath(String localRepoPath) { // todo decouple home folder resolution // find homedir String home = System.getenv("ZEPPELIN_HOME"); if (home == null) { home = System.getProperty("zeppelin.home"); } if (home == null) { home = ".."; } return Paths.get(home).resolve(localRepoPath).toAbsolutePath().toString(); }
public JavapProcess() throws FileNotFoundException { super(); Path javaHome = Paths.get(System.getProperty("java.home")); executablePath = Paths.get(javaHome.toString(), "..", "bin", EXECUTABLE_NAME); if (!executablePath.toFile().exists()) { executablePath = Paths.get(javaHome.toString(), "bin", EXECUTABLE_NAME); if (!executablePath.toFile().exists()) { throw new FileNotFoundException("Could not find " + EXECUTABLE_NAME); } } executablePath = executablePath.normalize(); }
@Override public boolean apply(@Nullable URL input) { try { if (input == null) { return false; } final String fName = Paths.get(input.toURI()).getFileName().toString(); return fName.startsWith("druid") && fName.endsWith(".jar") && !fName.endsWith("selfcontained.jar"); } catch (URISyntaxException e) { throw Throwables.propagate(e); } } };
@Override public void visitFile(Path file, String relative) throws IOException { if (file.getFileName().toString().endsWith(".class")) { Files.copy(file, outRoot.resolve(relative)); } } });
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relativePath = oldApkPath.relativize(file); Path newPath = newApkPath.resolve(relativePath); String patternKey = relativePath.toString().replace("\\", "/"); if (Utils.checkFileInPattern(config.mResFilePattern, patternKey)) { //not contain in new path, is deleted if (!newPath.toFile().exists()) { deletedFiles.add(patternKey); writeResLog(newPath.toFile(), file.toFile(), TypedValue.DEL); } return FileVisitResult.CONTINUE; } return FileVisitResult.CONTINUE; } }
@Override public File[] listFiles( File directory, final FilenameFilter filter ) { try ( Stream<Path> listing = Files.list( path( directory ) ) ) { return listing .filter( entry -> filter.accept( entry.getParent().toFile(), entry.getFileName().toString() ) ) .map( Path::toFile ) .toArray( File[]::new ); } catch ( IOException e ) { return null; } }
private String getSparkexJar() { try { Path path = Paths.get(EnableSparkSupportMagicCommand.class.getProtectionDomain().getCodeSource().getLocation().toURI()); return path.getParent().getParent().getParent().resolve("sparkex").resolve("lib").resolve("sparkex.jar").toString(); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * @return the name of current folder */ public static String getCurrentFolder() { return Paths.get("").toAbsolutePath().getFileName().toString(); }
public void stopFlinkCluster() throws IOException { AutoClosableProcess.runBlocking("Stop Flink Cluster", bin.resolve("stop-cluster.sh").toAbsolutePath().toString()); }
/** * Setup a file to archive data flow. Create archive directory if it doesn't exist yet. * @return Resolved archive file which is ready to write to * @throws IOException when it fails to access archive dir */ public File setupArchiveFile() throws IOException { Files.createDirectories(archiveDir); if (!Files.isDirectory(archiveDir)) { throw new IOException("Archive directory doesn't appear to be a directory " + archiveDir); } final String originalFlowConfigFileName = flowConfigFile.getFileName().toString(); final Path archiveFile = archiveDir.resolve(createArchiveFileName(originalFlowConfigFileName)); return archiveFile.toFile(); }
private String buildGemfilePath(final String bundleDirectoryString) throws ProvisionException { final Path bundleDirectory; try { bundleDirectory = Paths.get(bundleDirectoryString); } catch (InvalidPathException ex) { throw new ProvisionException("Bundle directory is invalid: \"" + bundleDirectoryString + "\"", ex); } return bundleDirectory.toAbsolutePath().resolve("Gemfile").toString(); }
private static Path determineEntryDestination( ArchiveEntry entry, Path databaseDestination, Path transactionLogsDirectory ) { String entryName = Paths.get( entry.getName() ).getFileName().toString(); return TransactionLogFiles.DEFAULT_FILENAME_FILTER.accept( null, entryName ) ? transactionLogsDirectory : databaseDestination; }