### Question:
FileUtil { public static void saveBitmap(Bitmap bitmap, File targetFile, int quality) throws IOException { saveBitmap(bitmap, targetFile, Bitmap.CompressFormat.JPEG, quality); } private  FileUtil(); static void write(String text, File target); static Uri getUri(Context context, String authority, File file); static void saveBitmap(Bitmap bitmap, File targetFile, int quality); static void saveBitmap(Bitmap bitmap, File targetFile, Bitmap.CompressFormat format, int quality); static void zip(List<File> sources, File target); static List<File> walk(File source); static List<File> walk(List<File> sources); static String uniqueName(File source, Set<String> taken); static String getFileExtension(File file); static String getFileNameWithoutExtention(File file);  }### Answer:
@Test public void saveBitmap() throws Exception { final Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565); FileUtil.saveBitmap(bitmap, file, 100); final Bitmap result = BitmapFactory.decodeFile(FILE_NAME); Assert.assertEquals(100, result.getHeight()); Assert.assertEquals(100, result.getWidth()); }
@Test public void saveBitmapWithConfig() throws Exception { final Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565); FileUtil.saveBitmap(bitmap, file, Bitmap.CompressFormat.PNG, 100); final BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Bitmap.Config.RGB_565; final Bitmap result = BitmapFactory.decodeFile(FILE_NAME, opts); Assert.assertEquals(100, result.getHeight()); Assert.assertEquals(100, result.getWidth()); Assert.assertEquals(bitmap.getPixel(0, 0), result.getPixel(0, 0)); }