List of usage examples for java.nio.file Path getFileName
Path getFileName();
From source file:de.dal33t.powerfolder.util.AddLicenseHeader.java
public static void addLicInfoToDir(Path dir) { Filter<Path> filter = new Filter<Path>() { @Override/* w w w . j a va 2s . com*/ public boolean accept(Path entry) { return entry.getFileName().toString().endsWith(".java"); } }; try (DirectoryStream<Path> javas = Files.newDirectoryStream(dir, filter)) { for (Path file : javas) { addLicInfo(file); } } catch (IOException ioe) { // TODO: } filter = new Filter<Path>() { @Override public boolean accept(Path entry) { return Files.isDirectory(entry); } }; try (DirectoryStream<Path> subDirs = Files.newDirectoryStream(dir, filter)) { for (Path subDir : subDirs) { addLicInfoToDir(subDir); } } catch (IOException ioe) { // TODO: } }
From source file:com.teradata.tempto.internal.convention.SqlTestsFileUtils.java
public static Path changeExtension(Path source, String extension) { String newFileName = changeExtension(extension, source.getFileName().toString()); return source.getParent().resolve(newFileName); }
From source file:hrytsenko.csv.App.java
/** * Executes script with given arguments. * /*w ww. j ava 2 s. co m*/ * <p> * First argument should contain path to file with script. Other arguments are optional and they will be passed into * scripts as is. * * @param args * arguments for execution. */ private static void execute(String[] args) throws ParseException, IOException { Args parsedArgs = parseArgs(args); Binding binding = new Binding(singletonMap("args", parsedArgs.getValues())); GroovyShell shell = new GroovyShell(binding, configuration()); executeEmbeddedScripts(shell); for (String script : parsedArgs.getScripts()) { Path path = Paths.get(script); LOGGER.info("Execute: {}.", path.getFileName()); try (BufferedReader reader = newBufferedReader(path, UTF_8)) { shell.evaluate(reader); } } }
From source file:fr.cnrs.sharp.reasoning.Interlinking.java
/** * Generates a Jena Model with an SHA-512 fingerprint of a file content. * @param inputRawFile the file to be fingerprinted * @return a Jena Model with an SHA-512, based on PROV and tavernaprov vocabularies. * @throws IOException//from w w w .j av a2 s .c o m */ public static Model fingerprint(Path inputRawFile) throws IOException { StopWatch sw = new StopWatch(); sw.start(); Model data = ModelFactory.createDefaultModel(); Path p = inputRawFile; String label = p.getFileName().toString(); System.out.println(); FileInputStream fis = new FileInputStream(p.toFile()); String sha512 = DigestUtils.sha512Hex(fis); StringBuffer sb = new StringBuffer(); sb.append("@base <http://fr.symetric> .\n" + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n" + "@prefix prov: <http://www.w3.org/ns/prov#> .\n" + "@prefix tavernaprov: <http://ns.taverna.org.uk/2012/tavernaprov/> .\n" + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"); sb.append("<#" + UUID.randomUUID().toString() + ">\n" + "\t a prov:Entity ;\n"); sb.append("\t rdfs:label \"" + label + "\"^^xsd:String ;\n"); sb.append("\t tavernaprov:sha512 \"" + sha512 + "\"^^xsd:String ."); RDFDataMgr.read(data, new StringReader(sb.toString()), null, Lang.TTL); fis.close(); return data; }
From source file:de.bund.bfr.pmfml.file.CombineArchiveUtil.java
static URI getModelURI(Path path) { String filename = path.getFileName().toString().toLowerCase(); if (filename.endsWith(".pmf")) return URIS.sbml; if (filename.endsWith(".pmfx") || filename.endsWith(".fskx")) return URIS.pmf; throw new IllegalArgumentException("Not supported file: " + path); }
From source file:com.basistech.rosette.apimodel.NonNullTest.java
@Parameterized.Parameters(name = "{0}") public static Collection<Object[]> data() throws URISyntaxException, IOException { File dir = new File("src/test/data"); Collection<Object[]> params = new ArrayList<>(); try (DirectoryStream<Path> paths = Files.newDirectoryStream(dir.toPath())) { for (Path file : paths) { if (file.toString().endsWith(".json")) { String className = file.getFileName().toString().replace(".json", ""); params.add(new Object[] { NonNullTest.class.getPackage().getName() + "." + className, file.toFile() }); }//from w w w . ja va 2 s . c o m } } return params; }
From source file:com.liferay.sync.engine.util.MSOfficeFileUtil.java
public static boolean isTempCreatedFile(Path filePath) { String fileName = String.valueOf(filePath.getFileName()); if ((fileName.startsWith("~$") || ((fileName.startsWith("~") || fileName.startsWith("ppt") || fileName.startsWith("pub")) && fileName.endsWith(".tmp"))) && !Files.isDirectory(filePath)) { return true; }/*w w w. ja v a 2 s .c om*/ Matcher matcher = _tempCreatedFilePattern.matcher(String.valueOf(filePath.getFileName())); if (matcher.matches() && !Files.isDirectory(filePath)) { return true; } return false; }
From source file:edu.cornell.mannlib.vitro.webapp.servlet.setup.RDFFilesLoader.java
private static String getRdfFormat(Path p) { String filename = p.getFileName().toString().toLowerCase(); if (filename.endsWith("n3")) return "N3"; else if (filename.endsWith("ttl")) return "TURTLE"; else/*from w w w . java 2 s . c o m*/ return DEFAULT_RDF_FORMAT; }
From source file:com.surevine.gateway.scm.git.jgit.TestUtility.java
public static void destroyTestRepo(final LocalRepoBean repoBean) throws Exception { final Path parent = repoBean.getRepoDirectory().getParent(); if (parent.getFileName().toString().startsWith("test_")) { FileUtils.deleteDirectory(repoBean.getRepoDirectory().getParent().toFile()); }/*ww w . ja v a 2s . c o m*/ }
From source file:com.datazuul.iiif.presentation.api.ManifestGenerator.java
private static void addPage(String urlPrefix, String imageDirectoryName, List<Canvas> canvases, int pageCounter, Path file) throws IOException, URISyntaxException { Path fileName = file.getFileName(); System.out.println(fileName.toAbsolutePath()); BufferedImage bimg = ImageIO.read(file.toFile()); int width = bimg.getWidth(); int height = bimg.getHeight(); // add a new page Canvas canvas1 = new Canvas(urlPrefix + imageDirectoryName + "/canvas/canvas-" + pageCounter, "p-" + pageCounter, height, width); canvases.add(canvas1);/* w ww . j av a2 s . co m*/ List<Image> images = new ArrayList<>(); canvas1.setImages(images); Image image1 = new Image(); image1.setOn(canvas1.getId()); images.add(image1); ImageResource imageResource1 = new ImageResource( urlPrefix + imageDirectoryName + "/" + fileName.toString()); imageResource1.setHeight(height); imageResource1.setWidth(width); image1.setResource(imageResource1); Service service1 = new Service(urlPrefix + imageDirectoryName + "/" + fileName.toString() + "?"); service1.setContext("http://iiif.io/api/image/2/context.json"); service1.setProfile("http://iiif.io/api/image/2/level1.json"); imageResource1.setService(service1); }