@Test public void testReadByteFromFile() throws IOException { File image = new File("core/src/test/resources/jerrymouse.jpeg"); byte[] bytes = FileUtils.readBytes(image); long length = image.length(); assertEquals(length, bytes.length); }
public static byte[] readBytes(File image) throws IOException { List<Byte> bytes = new ArrayList<>(); try (InputStream inputStream = new FileInputStream(image)) { int read; while ((read = inputStream.read()) != -1) { byte newByte = (byte) read; bytes.add(newByte); } } return Bytes.toArray(bytes); }
FileUtils { public static byte[] readBytes(File image) throws IOException { List<Byte> bytes = new ArrayList<>(); try (InputStream inputStream = new FileInputStream(image)) { int read; while ((read = inputStream.read()) != -1) { byte newByte = (byte) read; bytes.add(newByte); } } return Bytes.toArray(bytes); } }
FileUtils { public static byte[] readBytes(File image) throws IOException { List<Byte> bytes = new ArrayList<>(); try (InputStream inputStream = new FileInputStream(image)) { int read; while ((read = inputStream.read()) != -1) { byte newByte = (byte) read; bytes.add(newByte); } } return Bytes.toArray(bytes); }  }
FileUtils { public static byte[] readBytes(File image) throws IOException { List<Byte> bytes = new ArrayList<>(); try (InputStream inputStream = new FileInputStream(image)) { int read; while ((read = inputStream.read()) != -1) { byte newByte = (byte) read; bytes.add(newByte); } } return Bytes.toArray(bytes); }  static URL[] parseSinglePathToUrls(String path); static byte[] readBytes(File image); static void deleteDir(File file); static byte[] readFileFromJar(File file, String path); }
FileUtils { public static byte[] readBytes(File image) throws IOException { List<Byte> bytes = new ArrayList<>(); try (InputStream inputStream = new FileInputStream(image)) { int read; while ((read = inputStream.read()) != -1) { byte newByte = (byte) read; bytes.add(newByte); } } return Bytes.toArray(bytes); }  static URL[] parseSinglePathToUrls(String path); static byte[] readBytes(File image); static void deleteDir(File file); static byte[] readFileFromJar(File file, String path);  }