} catch (Exception notInJarWithPath) { notInJarWithPath.printStackTrace(); notFoundOnFilesystemWithExtensionTackedOn.printStackTrace(); throw new RuntimeException(" Could not locate DBTYpe settings : " + matchString, notInJarWithPath);
static void delete(File file) { try { if (logger.isTraceEnabled()) logger.trace("Deleting {}", file); Files.delete(file.toPath()); } catch (NoSuchFileException e) { logger.error("Unable to delete {} as it does not exist, see debug log file for stack trace", file); if (logger.isDebugEnabled()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream ps = new PrintStream(baos)) { e.printStackTrace(ps); } logger.debug("Unable to delete {} as it does not exist, stack trace:\n {}", file, baos.toString()); } } catch (IOException e) { logger.error("Unable to delete {}", file, e); throw new RuntimeException(e); } }
static void delete(File file) { try { if (logger.isTraceEnabled()) logger.trace("Deleting {}", file); Files.delete(file.toPath()); } catch (NoSuchFileException e) { logger.error("Unable to delete {} as it does not exist, see debug log file for stack trace", file); if (logger.isDebugEnabled()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream ps = new PrintStream(baos)) { e.printStackTrace(ps); } logger.debug("Unable to delete {} as it does not exist, stack trace:\n {}", file, baos.toString()); } } catch (IOException e) { logger.error("Unable to delete {}", file, e); throw new RuntimeException(e); } }
static void delete(File file) { try { if (logger.isTraceEnabled()) logger.trace("Deleting {}", file); Files.delete(file.toPath()); } catch (NoSuchFileException e) { logger.error("Unable to delete {} as it does not exist, see debug log file for stack trace", file); if (logger.isDebugEnabled()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream ps = new PrintStream(baos)) { e.printStackTrace(ps); } logger.debug("Unable to delete {} as it does not exist, stack trace:\n {}", file, baos.toString()); } } catch (IOException e) { logger.error("Unable to delete {}", file, e); throw new RuntimeException(e); } }
static void delete(File file) { try { if (logger.isTraceEnabled()) logger.trace("Deleting {}", file); Files.delete(file.toPath()); } catch (NoSuchFileException e) { logger.error("Unable to delete {} as it does not exist, see debug log file for stack trace", file); if (logger.isDebugEnabled()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream ps = new PrintStream(baos)) { e.printStackTrace(ps); } logger.debug("Unable to delete {} as it does not exist, stack trace:\n {}", file, baos.toString()); } } catch (IOException e) { logger.error("Unable to delete {}", file, e); throw new RuntimeException(e); } }
@Test public void fileChannelCreate() throws Exception { try { Path test = fs.getPath("test.txt"); FileChannel.open(test, StandardOpenOption.WRITE, StandardOpenOption.CREATE).close(); } catch (NoSuchFileException ex) { System.err.println("Unexpected exception"); ex.printStackTrace(); // Bug in JDK } }
} catch (Exception notInJarWithPath) { notInJarWithPath.printStackTrace(); notFoundOnFilesystemWithExtensionTackedOn.printStackTrace(); throw new RuntimeException(" Could not locate DBTYpe settings : " + matchString, notInJarWithPath);
@Test public void setLastModifiedTime() throws Exception { Path root = fs.getRootDirectories().iterator().next(); Path folder = root.resolve("folder"); Files.createDirectory(folder); Path file = root.resolve("file"); Files.createFile(file); FileTime someTimeAgo = FileTime.from(365 * 12, TimeUnit.DAYS); Files.setLastModifiedTime(folder, someTimeAgo); Files.setLastModifiedTime(file, someTimeAgo); try { Files.setLastModifiedTime(root, someTimeAgo); } catch (NoSuchFileException ex) { System.err .println("Unexpected failure of setLastModifiedTime on root"); ex.printStackTrace(); } }