public static void displayScreenshotFile() { try { File screenshot = getScreenshotFile(); if (FileUtils.waitFor(screenshot, 1)) { log.info("Screenshot file available {}", screenshot.getAbsolutePath()); Desktop.getDesktop().open(screenshot); } else { log.warn("File {} not created", screenshot); } } catch (IOException e) { log.error("Cannot display screenshot due to", e); } }
private static void transformDataFile(File dataFile) throws IOException { Path origFile = Paths.get(dataFile.toURI()); List<List<String>> data = CsvToTable.readCsv(origFile); Files.deleteIfExists(Paths.get(dataFile.getAbsolutePath() + ".orig")); File movedFile = new File(dataFile.getAbsolutePath() + ".orig"); FileUtils.moveFile(dataFile, movedFile); FileUtils.waitFor(movedFile, 2); if (!transformedFiles.contains(dataFile.getAbsolutePath() + ".orig")) { transformedFiles.add(dataFile.getAbsolutePath() + ".orig"); } if (dataFile.getName().contains(CsvToTable.VERTICAL)) { data = CsvToTable.transform(data); } CsvToTable.writeAsTable(data, origFile); }
public static boolean waitFor(File file, int seconds) { return FileUtils.waitFor(file, seconds); }
/** * 延迟判断文件是否存在 * * @param file * @param timeout * @return */ public static boolean exist(File file, int timeout) { return FileUtils.waitFor(file, timeout); }