@Test public void testReadBytesFromFile() throws IOException { String filename = "build/bytes_test_file"; byte[] bytes = {1, 2, 3, 10, 11, 12}; Files.write(bytes, new File(filename)); byte[] result = FileSystemUtil.readBytesFromFile(filename); assertNotNull(result); assertThat(result, is(bytes)); }
@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; }