@Test(expected = InvalidImplementationException.class) public void testReadFileAsBytes() { byte[] bytes = FileUtil.readFileAsBytes("testing.txt"); byte[] expected = {105, 100, 101, 121, 97, 116, 101, 99, 104, 10, 115, 97, 109, 112, 108, 101, 32, 102, 105, 108, 101}; Assert.assertEquals(21,bytes.length); for (int i=0;i<expected.length; i++) { Assert.assertEquals(expected[i], bytes[i]); } try { FileUtil.readFileAsBytes("test/missing.txt"); fail("No Exception thrown with missing file."); } catch (Exception e) { } }
public static byte[] readFileAsBytes(File file) { try { InputStream is = FileUtil.getFileStream(file.getAbsolutePath()); return readFileAsBytes(is, file.getAbsolutePath()); } catch (FileNotFoundException fe) { String msg = "Failed to find file [" + file.getAbsolutePath() + "]."; _log.error(msg, fe); throw new InvalidImplementationException(msg, fe); } }
FileUtil { public static byte[] readFileAsBytes(File file) { try { InputStream is = FileUtil.getFileStream(file.getAbsolutePath()); return readFileAsBytes(is, file.getAbsolutePath()); } catch (FileNotFoundException fe) { String msg = "Failed to find file [" + file.getAbsolutePath() + "]."; _log.error(msg, fe); throw new InvalidImplementationException(msg, fe); } } }
FileUtil { public static byte[] readFileAsBytes(File file) { try { InputStream is = FileUtil.getFileStream(file.getAbsolutePath()); return readFileAsBytes(is, file.getAbsolutePath()); } catch (FileNotFoundException fe) { String msg = "Failed to find file [" + file.getAbsolutePath() + "]."; _log.error(msg, fe); throw new InvalidImplementationException(msg, fe); } } private  FileUtil(); }
FileUtil { public static byte[] readFileAsBytes(File file) { try { InputStream is = FileUtil.getFileStream(file.getAbsolutePath()); return readFileAsBytes(is, file.getAbsolutePath()); } catch (FileNotFoundException fe) { String msg = "Failed to find file [" + file.getAbsolutePath() + "]."; _log.error(msg, fe); throw new InvalidImplementationException(msg, fe); } } private  FileUtil(); static String readFile(File file); static String readFile(String filename); static byte[] readFileAsBytes(File file); static byte[] readFileAsBytes(String filename); static String backupFile(File source); static InputStream getFileStream(String name); static void writeFile(String filename, String content); static void appendFile(String filename, String content); static File createDirectory(String path); static boolean copyMultipartFile(final MultipartFile multipartFile,
			File dest); static Properties readProperty(File f); static void saveProperty(String filename, Properties properties, String header); static String getFilename(String filepath); }
FileUtil { public static byte[] readFileAsBytes(File file) { try { InputStream is = FileUtil.getFileStream(file.getAbsolutePath()); return readFileAsBytes(is, file.getAbsolutePath()); } catch (FileNotFoundException fe) { String msg = "Failed to find file [" + file.getAbsolutePath() + "]."; _log.error(msg, fe); throw new InvalidImplementationException(msg, fe); } } private  FileUtil(); static String readFile(File file); static String readFile(String filename); static byte[] readFileAsBytes(File file); static byte[] readFileAsBytes(String filename); static String backupFile(File source); static InputStream getFileStream(String name); static void writeFile(String filename, String content); static void appendFile(String filename, String content); static File createDirectory(String path); static boolean copyMultipartFile(final MultipartFile multipartFile,
			File dest); static Properties readProperty(File f); static void saveProperty(String filename, Properties properties, String header); static String getFilename(String filepath);  }