List of usage examples for java.nio.file Paths get
public static Path get(URI uri)
From source file:com.meplato.store2.MockResponse.java
/** * Parse a Response from a filename.//from www . j a va 2s .co m * * @param filename * @return Response * @throws IOException * @throws HttpException * @throws ServiceException */ public static Response fromFile(String filename) throws IOException, HttpException, ServiceException { return fromPath(Paths.get(filename)); }
From source file:ch.oakmountain.tpa.web.TpaWebPersistor.java
public static void createGraph(String name, String outputDir, GraphCSV csv, String htmlData) throws IOException { String content = IOUtils.toString(TpaWebPersistor.class.getResourceAsStream("/graph-curved.html")); content = content.replaceAll(Pattern.quote("$CSVNAME$"), Matcher.quoteReplacement(name)) .replaceAll(Pattern.quote("$HTML$"), Matcher.quoteReplacement(htmlData)); FileUtils.writeStringToFile(Paths.get(outputDir + File.separator + name + ".html").toFile(), content); FileUtils.writeStringToFile(new File(outputDir + File.separator + name + ".csv"), csv.toString()); TpaPersistorUtils.copyFromResourceToDir("d3.v3.js", outputDir); }
From source file:com.derpgroup.skillscraper.SkillsFileUtils.java
protected static void writeShitOut(Map<Skill, SkillReviewsResponse> skillReviewsBySkill) { long currentTime = System.currentTimeMillis(); String outputPath = String.format(jsonFileOutputRootPath + "%d/", currentTime); Path path = Paths.get(outputPath); try {//ww w . j a va 2s.co m Files.createDirectories(path); } catch (IOException e1) { e1.printStackTrace(); } for (Skill skill : skillReviewsBySkill.keySet()) { List<SkillReview> skillReviews = skillReviewsBySkill.get(skill).getTopReviews(); writeSkill(outputPath, skill, skillReviews); } }
From source file:heigit.ors.util.FileUtility.java
public static Boolean isAbsolutePath(String path) { Path path2 = Paths.get(path); return path2.isAbsolute(); }
From source file:com.arpnetworking.metrics.mad.performance.CollectdPipelinePT.java
@BeforeClass public static void setUp() throws IOException, URISyntaxException { // Extract the sample file final Path gzipPath = Paths.get(Resources.getResource("collectd-sample1.log.gz").toURI()); final FileInputStream fileInputStream = new FileInputStream(gzipPath.toFile()); final GZIPInputStream gzipInputStream = new GZIPInputStream(fileInputStream); final Path path = Paths.get("target/tmp/perf/collectd-sample1.log"); final FileOutputStream outputStream = new FileOutputStream(path.toFile()); IOUtils.copy(gzipInputStream, outputStream); JSON_BENCHMARK_CONSUMER.prepareClass(); }
From source file:pl.p.lodz.ftims.server.logic.ChallengeServiceTest.java
@BeforeClass public static void createImgDir() throws IOException { if (Files.notExists(Paths.get(PHOTOS_DIR), LinkOption.NOFOLLOW_LINKS)) { Files.createDirectory(Paths.get(PHOTOS_DIR)); }//from ww w . ja v a2 s. c o m }
From source file:com.orange.ngsi2.Utils.java
/** * Load a resource as an UTF-8 string//ww w. j a v a 2 s. c om * @param name name of the resource * @return the content of the resource */ public static String loadResource(String name) { try { URL url = Utils.class.getClassLoader().getResource(name); if (url == null) { return ""; } return new String(Files.readAllBytes(Paths.get(url.toURI())), "UTF-8"); } catch (Exception e) { return ""; } }
From source file:dev.meng.wikipedia.profiler.Cleaner.java
public static void cleanLog(List<String> values) { for (String value : values) { for (LogLevel level : LogLevel.values()) { try { Path filepath = Paths.get(value + "-" + level.name().toLowerCase() + ".log"); Files.deleteIfExists(filepath); } catch (IOException ex) { LogHandler.console(Cleaner.class, ex); }// w w w.j av a2 s . c om } } }
From source file:azkaban.execapp.AzkabanExecutorServerTest.java
private static String getSqlScriptsDir() throws IOException { // Dummy because any resource file works. URL resource = AzkabanExecutorServerTest.class.getClassLoader().getResource("test.file"); final String dummyResourcePath = requireNonNull(resource).getPath(); Path resources = Paths.get(dummyResourcePath).getParent(); Path azkabanRoot = resources.getParent().getParent().getParent().getParent(); File sqlScriptDir = Paths.get(azkabanRoot.toString(), AZKABAN_DB_SQL_PATH).toFile(); return props.getString(AzkabanDatabaseSetup.DATABASE_SQL_SCRIPT_DIR, sqlScriptDir.getCanonicalPath()); }
From source file:hr.fer.tel.rovkp.homework03.task01.JokesCollection.java
public static Map<Integer, String> parseInputFile(String file) throws IOException { Path filePath = Paths.get(file); Map<Integer, String> results = new HashMap<>(); List<String> currentJoke = new LinkedList<>(); LinkedList<Integer> ids = new LinkedList<>(); try (Stream<String> stream = Files.lines(filePath)) { stream.forEach(line -> {/* w ww .j ava 2 s. co m*/ if (line == null) return; line = line.trim(); if (line.isEmpty() && !currentJoke.isEmpty()) { int currentId = ids.getLast(); String jokeText = StringUtils.join(currentJoke, "\n"); jokeText = StringEscapeUtils.unescapeXml(jokeText.toLowerCase().replaceAll("\\<.*?\\>", "")); if (results.putIfAbsent(currentId, jokeText) != null) System.err.println("Joke with id " + currentId + "already exists. Not overwriting."); } else if (line.matches("^[0-9]+:$")) { ids.addLast(Integer.parseInt(line.substring(0, line.length() - 1))); currentJoke.clear(); } else { currentJoke.add(line); } }); } return results; }