public static int patchFast(InputStream oldInputStream,InputStream diffInputStream,File newFile) throws IOException {
  if (oldInputStream == null) {
    return RETURN_OLD_FILE_ERR;
  }
  if (newFile == null) {
    return RETURN_NEW_FILE_ERR;
  }
  if (diffInputStream == null) {
    return RETURN_DIFF_FILE_ERR;
  }
  byte[] oldBytes=BSUtil.inputStreamToByte(oldInputStream);
  byte[] diffBytes=BSUtil.inputStreamToByte(diffInputStream);
  byte[] newBytes=patchFast(oldBytes,oldBytes.length,diffBytes,diffBytes.length,0);
  OutputStream newOutputStream=new FileOutputStream(newFile);
  try {
    newOutputStream.write(newBytes);
  }
  finally {
    newOutputStream.close();
  }
  return RETURN_SUCCESS;
}

public static int patchFast ( InputStream oldInputStream , InputStream diffInputStream , File newFile ) throws IOException { if ( oldInputStream == null ) { return RETURN_OLD_FILE_ERR ; } if ( newFile == null ) { return RETURN_NEW_FILE_ERR ; } if ( diffInputStream == null ) { return RETURN_DIFF_FILE_ERR ; } byte [ ] oldBytes = BSUtil . inputStreamToByte ( oldInputStream ) ; byte [ ] diffBytes = BSUtil . inputStreamToByte ( diffInputStream ) ; byte [ ] newBytes = patchFast ( oldBytes , oldBytes . length , diffBytes , diffBytes . length , 0 ) ; OutputStream newOutputStream = new FileOutputStream ( newFile ) ; try { newOutputStream . write ( newBytes ) ; } finally { newOutputStream . close ( ) ; } return RETURN_SUCCESS ; }
this patch method is fast , but using more memory . memory size = oldbuf + diffbuf + newbuf
