private static void applyDiff(InputStream patchInput, /* @Nullable */ InputStream oldFileIn, OutputStream toFileOut) throws IOException {
    int type = patchInput.read();
    if (type == COMPRESSED) {
      if (oldFileIn == null) throw new RuntimeException("File in local installation missing");
      JBPatch.bspatch(oldFileIn, toFileOut, patchInput);
    }
    else if (type == RAW) {
      Utils.copyStream(patchInput, toFileOut);
    }
    else {
      throw new IOException("Corrupted patch");
    }
  }
private static void applyDiff(InputStream patchInput, /* @Nullable */ InputStream oldFileIn, OutputStream toFileOut)