UPS extends Patcher { public static boolean checkMagic(File f) throws IOException { FileInputStream stream = null; try { stream = new FileInputStream(f); byte[] buffer = new byte[4]; stream.read(buffer); return Arrays.equals(buffer, MAGIC_NUMBER); } finally { IOUtils.closeQuietly(stream); } } UPS(Context context, File patch, File rom, File output); @Override void apply(boolean ignoreChecksum); static boolean checkMagic(File f); static UpsCrc readUpsCrc(Context context, File f);  }
@Test public void testCheckMagic() throws Exception { File patch = new File(this.getClass().getResource("/ups/readUpsCrc.ups").getPath()); assertTrue(UPS.checkMagic(patch)); File noPatch = new File(this.getClass().getResource("/ups/readUpsCrc.bin").getPath()); assertFalse(UPS.checkMagic(noPatch)); }