FileUtils { public static PrintWriter openPrintWriterToFile(File file, boolean verbose) throws AdeUsageException { try { if (verbose) { logger.info("Opening " + file.getPath()); } return new PrintWriter(file, FILE_ENCODING); } catch (FileNotFoundException e) { throw new AdeUsageException("Cannot open file " + file.getPath(), e); } catch (UnsupportedEncodingException e) { throw new AdeUsageException("Platform does not support encoding " + FILE_ENCODING, e); } } private  FileUtils(); static void createDir(File target); static void createDirs(File target); static File[] listFilesSorted(File directory); static PrintWriter openPrintWriterToFile(File file, boolean verbose); static void assertExists(File... files);  }
@Test public void testOpenPrintWriterToFileSuccessOnExistingFile() throws Exception { assertNotNull("Assert method returns PrintWriter", FileUtils.openPrintWriterToFile(tempFolder.newFile(), false)); }
@Test(expected = AdeUsageException.class) public void testOpenPrintWriterToFileThrowsAdeUsageException() throws Exception { FileUtils.openPrintWriterToFile(new File("/xxx/xxx/xxx/badfile"), false); }