@Test public void testAssertFileExists() { FileSystemUtil.assertFileOrResourceExists("build.gradle"); try { FileSystemUtil.assertFileOrResourceExists("/not/existing/file"); fail("IllegalArgumentException expected"); } catch(IllegalArgumentException e) { assertThat(e.getMessage(), startsWith("File not found: ")); } }
public static void assertFileOrResourceExists(String filename) { if (!checkFileOrResourceExists(filename)) { String msg = "File not found: " + FileNameUtil.getCanonicalPath(filename); LOGGER.error(msg); throw new IllegalArgumentException(msg); } }
FileSystemUtil { public static void assertFileOrResourceExists(String filename) { if (!checkFileOrResourceExists(filename)) { String msg = "File not found: " + FileNameUtil.getCanonicalPath(filename); LOGGER.error(msg); throw new IllegalArgumentException(msg); } } }
FileSystemUtil { public static void assertFileOrResourceExists(String filename) { if (!checkFileOrResourceExists(filename)) { String msg = "File not found: " + FileNameUtil.getCanonicalPath(filename); LOGGER.error(msg); throw new IllegalArgumentException(msg); } } private  FileSystemUtil(); }
FileSystemUtil { public static void assertFileOrResourceExists(String filename) { if (!checkFileOrResourceExists(filename)) { String msg = "File not found: " + FileNameUtil.getCanonicalPath(filename); LOGGER.error(msg); throw new IllegalArgumentException(msg); } } private  FileSystemUtil(); static boolean checkFileOrResourceExists(String filename); static void assertFileOrResourceExists(String filename); static String readFileAsText(String filename); static String readFileAsText(String fileName, String alternateDir); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void writeStringToFile(String content, String filename); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void appendStringToFile(String content, String filename); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static byte[] readBytesFromFile(String filename); static void deleteDirectoryQuietly(String rootDirName); }
FileSystemUtil { public static void assertFileOrResourceExists(String filename) { if (!checkFileOrResourceExists(filename)) { String msg = "File not found: " + FileNameUtil.getCanonicalPath(filename); LOGGER.error(msg); throw new IllegalArgumentException(msg); } } private  FileSystemUtil(); static boolean checkFileOrResourceExists(String filename); static void assertFileOrResourceExists(String filename); static String readFileAsText(String filename); static String readFileAsText(String fileName, String alternateDir); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void writeStringToFile(String content, String filename); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void appendStringToFile(String content, String filename); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static byte[] readBytesFromFile(String filename); static void deleteDirectoryQuietly(String rootDirName); static final String CLASSPATH_PREFIX; }