source: josm/trunk/src/org/tukaani/xz/common/EncoderUtil.java@ 13573

Last change on this file since 13573 was 13350, checked in by stoecker, 7 years ago

see #15816 - add XZ support

File size: 868 bytes
Line 
1/*
2 * EncoderUtil
3 *
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
5 *
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
9
10package org.tukaani.xz.common;
11
12import java.io.OutputStream;
13import java.io.IOException;
14import java.util.zip.CRC32;
15
16public class EncoderUtil extends Util {
17 public static void writeCRC32(OutputStream out, byte[] buf)
18 throws IOException {
19 CRC32 crc32 = new CRC32();
20 crc32.update(buf);
21 long value = crc32.getValue();
22
23 for (int i = 0; i < 4; ++i)
24 out.write((byte)(value >>> (i * 8)));
25 }
26
27 public static void encodeVLI(OutputStream out, long num)
28 throws IOException {
29 while (num >= 0x80) {
30 out.write((byte)(num | 0x80));
31 num >>>= 7;
32 }
33
34 out.write((byte)num);
35 }
36}
Note: See TracBrowser for help on using the repository browser.