List of usage examples for java.nio.file Path resolve
default Path resolve(String other)
From source file:Test.java
public static void main(String[] args) { Path rootPath = Paths.get("/home/docs"); Path resolvedPath = rootPath.resolve("backup/users.txt"); }
From source file:Test.java
public static void main(String[] args) { Path rootPath = Paths.get("/home/docs"); Path resolvedPath = rootPath.resolve("backup/users.txt"); resolvedPath = rootPath.resolve("tmp/A.mp3"); System.out.println("rootPath: " + rootPath); System.out.println("resolvedPath: " + resolvedPath); System.out.println();/*from www . ja v a 2s.c o m*/ resolvedPath = rootPath.resolveSibling("tmp/A.mp3"); System.out.println("rootPath: " + rootPath); System.out.println("resolvedPath: " + resolvedPath); }
From source file:Test.java
public static void main(String[] args) { Path rootPath = Paths.get("/home/docs"); Path partialPath = Paths.get("users.txt"); Path resolvedPath = rootPath.resolve(partialPath); }
From source file:Main.java
public static void main(String[] args) { Path path = Paths.get("C:/home/./music/users.txt"); Path path1 = Paths.get("./music/users.txt"); System.out.println(path.resolve(path1).normalize()); }
From source file:Main.java
public static void main(String[] args) { //define the fix path Path base_1 = Paths.get("C:/tutorial/Java/JavaFX"); Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt"); //resolve Topic.txt file Path path_1 = base_1.resolve("Topic.txt"); System.out.println(path_1.toString()); //resolve Demo.txt file Path path_2 = base_1.resolve("Demo.txt"); System.out.println(path_2.toString()); }
From source file:Main.java
public static void main(String[] args) { Path rootPath = Paths.get("c:/home/docs"); System.out.println(rootPath); Path partialPath = Paths.get("users.txt"); System.out.println(partialPath); Path resolvedPath = rootPath.resolve(partialPath); System.out.println(resolvedPath); }
From source file:ru.histone.staticrender.StaticRender.java
public static void main(String... args) throws IOException { Path workDir = Paths.get(".").toRealPath(); log.info("Working dir={}", workDir.toString()); Path srcDir = workDir.resolve("src/site"); Path dstDir = workDir.resolve("build/site"); StaticRender app = new StaticRender(); app.renderSite(srcDir, dstDir);//w ww. j a v a 2s .c o m }
From source file:edu.jhu.hlt.concrete.ingesters.webposts.WebPostIngesterRunner.java
/** * @param args/*from www . j a va 2 s .co m*/ */ public static void main(String... args) { Thread.setDefaultUncaughtExceptionHandler(new LoggedUncaughtExceptionHandler()); WebPostIngesterRunner run = new WebPostIngesterRunner(); JCommander jc = new JCommander(run, args); jc.setProgramName(WebPostIngesterRunner.class.getSimpleName()); if (run.delegate.help) { jc.usage(); } try { Path outpath = Paths.get(run.delegate.outputPath); IngesterParameterDelegate.prepare(outpath); WebPostIngester ing = new WebPostIngester(); Path outWithExt = outpath.resolve("webposts.tar.gz"); if (Files.exists(outWithExt)) { if (!run.delegate.overwrite) { LOGGER.info("File: {} exists and overwrite disabled. Not running.", outWithExt.toString()); return; } else { Files.delete(outWithExt); } } try (OutputStream os = Files.newOutputStream(outWithExt); GzipCompressorOutputStream gout = new GzipCompressorOutputStream(os); TarArchiver arch = new TarArchiver(gout)) { for (String pstr : run.delegate.paths) { LOGGER.debug("Running on file: {}", pstr); Path p = Paths.get(pstr); new ExistingNonDirectoryFile(p); try { Communication next = ing.fromCharacterBasedFile(p); arch.addEntry(new ArchivableCommunication(next)); } catch (IngestException e) { LOGGER.error("Error processing file: " + pstr, e); } } } } catch (NotFileException | IOException e) { LOGGER.error("Caught exception processing.", e); } }
From source file:edu.jhu.hlt.concrete.ingesters.bolt.BoltIngesterRunner.java
/** * @param args/*from w ww .j a va 2s .c o m*/ */ public static void main(String... args) { Thread.setDefaultUncaughtExceptionHandler(new LoggedUncaughtExceptionHandler()); BoltIngesterRunner run = new BoltIngesterRunner(); JCommander jc = new JCommander(run, args); jc.setProgramName(BoltIngesterRunner.class.getSimpleName()); if (run.delegate.help) { jc.usage(); } try { Path outpath = Paths.get(run.delegate.outputPath); IngesterParameterDelegate.prepare(outpath); BoltForumPostIngester ing = new BoltForumPostIngester(); Path outWithExt = outpath.resolve("bolt.tar.gz"); if (Files.exists(outWithExt)) { if (!run.delegate.overwrite) { LOGGER.info("File: {} exists and overwrite disabled. Not running.", outWithExt.toString()); return; } else { Files.delete(outWithExt); } } try (OutputStream os = Files.newOutputStream(outWithExt); GzipCompressorOutputStream gout = new GzipCompressorOutputStream(os); TarArchiver arch = new TarArchiver(gout)) { for (Path p : run.delegate.findFilesInPaths()) { LOGGER.debug("Running on file: {}", p); new ExistingNonDirectoryFile(p); try { Communication next = ing.fromCharacterBasedFile(p); arch.addEntry(new ArchivableCommunication(next)); } catch (IngestException e) { LOGGER.error("Error processing file: " + p, e); } } } } catch (NotFileException | IOException e) { LOGGER.error("Caught exception processing.", e); } }
From source file:edu.jhu.hlt.concrete.ingesters.simple.CompleteFileIngester.java
/** * See usage string.// ww w.j av a2s . c o m * * @param args */ public static void main(String[] args) { if (args.length != 3) { System.err.println("This program converts a character-based file to a .concrete file."); System.err.println("The text file must contain UTF-8 encoded characters."); System.err.println( "The .concrete file will share the same name as the input file, including the extension."); System.err.println("This program takes 3 arguments."); System.err.println("Argument 1: path/to/a/character/based/file"); System.err.println("Argument 2: type of Communication to generate [e.g., tweet]"); System.err.println("Argument 3: path/to/output/folder"); System.err.println("Example usage: " + CompleteFileIngester.class.getName() + " /my/text/file story /my/output/folder"); System.exit(1); } String inPathStr = args[0]; Path inPath = Paths.get(inPathStr); try { ExistingNonDirectoryFile ef = new ExistingNonDirectoryFile(inPath); Optional<String> commType = Optional.ofNullable(args[1]); Optional<String> outPathStr = Optional.ofNullable(args[2]); Path ep = ef.getPath(); String fn = ef.getName(); Path outPath = Paths.get(outPathStr.get()); Path outFile = outPath.resolve(fn + ".concrete"); // Output directory exists, or it doesn't. // Try to create if it does not. if (!Files.exists(outPath)) { try { Files.createDirectories(outPath); } catch (IOException e) { logger.error("Caught exception when making output directories.", e); } // if it does, check to make sure it's a directory. } else { if (!Files.isDirectory(outPath)) { logger.error("Output path exists but is not a directory."); System.exit(1); } else { // check to make sure the output file won't be overwritten. if (Files.exists(outFile)) { logger.warn("Output file {} exists; not overwriting.", outFile.toString()); System.exit(1); } } } try { UTF8FileIngester ing = new CompleteFileIngester(commType.get()); Communication comm = ing.fromCharacterBasedFile(ep); new WritableCommunication(comm).writeToFile(outFile, false); } catch (IngestException e) { logger.error("Caught exception during ingest.", e); System.exit(1); } catch (ConcreteException e) { logger.error("Caught exception writing output.", e); } } catch (NoSuchFileException e) { logger.error("Path {} does not exist.", inPathStr); System.exit(1); } catch (NotFileException e) { logger.error("Path {} is a directory.", inPathStr); System.exit(1); } }