public class BsPatch extends Object
Example:
// origFile is the original file to be patched
String origFile = "original-file.txt"; //$NON-NLS-1$
// patchFile provides the patch, as generated by bsdiff
String patchFile = "original-file.patch"; //$NON-NLS-1$
// resFile will contain the result of the patch operation
String resFile = "result-file.txt"; //$NON-NLS-1$
int blockBufferSize = 512;
try (RandomAccessFile raf = new RandomAccessFile(origFile, "r"); //$NON-NLS-1$
InputStream is = deflate(patchFile);
OutputStream fos = new FileOutputStream(resFile)) {
// apply the patch
BsPatch.run(raf, fos, is, blockBufferSize);
}
Note that the patchFile is typically stored in a compressed format.
| Modifier and Type | Method and Description |
|---|---|
static void |
run(RandomAccessFile inputFile,
OutputStream outputStream,
InputStream patchStream,
int blockBufferSize)
Applies the patch on a file.
|
public static void run(RandomAccessFile inputFile, OutputStream outputStream, InputStream patchStream, int blockBufferSize) throws IOException
inputFile - the file on which the patch should be applied.outputStream - the stream where to write the output of the operation.patchStream - the stream providing the patch to apply.blockBufferSize - the size of the block buffer.IOException