@Test public void testReadBytesFromFileNotExisting() { String filename = "build/not_existing_file"; try { FileSystemUtil.readBytesFromFile(filename); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertThat(e.getMessage().startsWith("Error reading file "), is(true)); } }
@SuppressWarnings("squid:S1166") public static byte[] readBytesFromFile(String filename) { File file = new File(filename); try { return Files.toByteArray(file); } catch (IOException e) { String msg = String.format("Error reading file %s: %s", file.getAbsolutePath(), e.getMessage()); LOGGER.error(msg); throw new IllegalArgumentException(msg, e); } }
FileSystemUtil { @SuppressWarnings("squid:S1166") public static byte[] readBytesFromFile(String filename) { File file = new File(filename); try { return Files.toByteArray(file); } catch (IOException e) { String msg = String.format("Error reading file %s: %s", file.getAbsolutePath(), e.getMessage()); LOGGER.error(msg); throw new IllegalArgumentException(msg, e); } } }
FileSystemUtil { @SuppressWarnings("squid:S1166") public static byte[] readBytesFromFile(String filename) { File file = new File(filename); try { return Files.toByteArray(file); } catch (IOException e) { String msg = String.format("Error reading file %s: %s", file.getAbsolutePath(), e.getMessage()); LOGGER.error(msg); throw new IllegalArgumentException(msg, e); } } private  FileSystemUtil(); }
FileSystemUtil { @SuppressWarnings("squid:S1166") public static byte[] readBytesFromFile(String filename) { File file = new File(filename); try { return Files.toByteArray(file); } catch (IOException e) { String msg = String.format("Error reading file %s: %s", file.getAbsolutePath(), e.getMessage()); LOGGER.error(msg); throw new IllegalArgumentException(msg, e); } } 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 { @SuppressWarnings("squid:S1166") public static byte[] readBytesFromFile(String filename) { File file = new File(filename); try { return Files.toByteArray(file); } catch (IOException e) { String msg = String.format("Error reading file %s: %s", file.getAbsolutePath(), e.getMessage()); LOGGER.error(msg); throw new IllegalArgumentException(msg, e); } } 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; }