private static boolean extractDexToJar(ZipFile zipFile,ZipEntry entryFile,File extractTo,String targetMd5) throws IOException {
  int numAttempts=0;
  boolean isExtractionSuccessful=false;
  while (numAttempts < MAX_EXTRACT_ATTEMPTS && !isExtractionSuccessful) {
    numAttempts++;
    FileOutputStream fos=new FileOutputStream(extractTo);
    InputStream in=zipFile.getInputStream(entryFile);
    ZipOutputStream zos=null;
    BufferedInputStream bis=null;
    TinkerLog.i(TAG,"try Extracting " + extractTo.getPath());
    try {
      zos=new ZipOutputStream(new BufferedOutputStream(fos));
      bis=new BufferedInputStream(in);
      byte[] buffer=new byte[ShareConstants.BUFFER_SIZE];
      ZipEntry entry=new ZipEntry(ShareConstants.DEX_IN_JAR);
      zos.putNextEntry(entry);
      int length=bis.read(buffer);
      while (length != -1) {
        zos.write(buffer,0,length);
        length=bis.read(buffer);
      }
      zos.closeEntry();
    }
  finally {
      SharePatchFileUtil.closeQuietly(bis);
      SharePatchFileUtil.closeQuietly(zos);
    }
    isExtractionSuccessful=SharePatchFileUtil.verifyDexFileMd5(extractTo,targetMd5);
    TinkerLog.i(TAG,"isExtractionSuccessful: %b",isExtractionSuccessful);
    if (!isExtractionSuccessful) {
      extractTo.delete();
      if (extractTo.exists()) {
        TinkerLog.e(TAG,"Failed to delete corrupted dex " + extractTo.getPath());
      }
    }
  }
  return isExtractionSuccessful;
}

private static boolean extractDexToJar ( ZipFile zipFile , ZipEntry entryFile , File extractTo , String targetMd5 ) throws IOException { int numAttempts = 0 ; boolean isExtractionSuccessful = false ; while ( numAttempts < MAX_EXTRACT_ATTEMPTS && ! isExtractionSuccessful ) { numAttempts ++ ; FileOutputStream fos = new FileOutputStream ( extractTo ) ; InputStream in = zipFile . getInputStream ( entryFile ) ; ZipOutputStream zos = null ; BufferedInputStream bis = null ; TinkerLog . i ( TAG , "try Extracting " + extractTo . getPath ( ) ) ; try { zos = new ZipOutputStream ( new BufferedOutputStream ( fos ) ) ; bis = new BufferedInputStream ( in ) ; byte [ ] buffer = new byte [ ShareConstants . BUFFER_SIZE ] ; ZipEntry entry = new ZipEntry ( ShareConstants . DEX_IN_JAR ) ; zos . putNextEntry ( entry ) ; int length = bis . read ( buffer ) ; while ( length != - 1 ) { zos . write ( buffer , 0 , length ) ; length = bis . read ( buffer ) ; } zos . closeEntry ( ) ; } finally { SharePatchFileUtil . closeQuietly ( bis ) ; SharePatchFileUtil . closeQuietly ( zos ) ; } isExtractionSuccessful = SharePatchFileUtil . verifyDexFileMd5 ( extractTo , targetMd5 ) ; TinkerLog . i ( TAG , "isExtractionSuccessful: %b" , isExtractionSuccessful ) ; if ( ! isExtractionSuccessful ) { extractTo . delete ( ) ; if ( extractTo . exists ( ) ) { TinkerLog . e ( TAG , "Failed to delete corrupted dex " + extractTo . getPath ( ) ) ; } } } return isExtractionSuccessful ; }
repack dex to jar
