当前位置: 首页>>代码示例>>Java>>正文


Java CheckedOutputStream.write方法代码示例

本文整理汇总了Java中java.util.zip.CheckedOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java CheckedOutputStream.write方法的具体用法?Java CheckedOutputStream.write怎么用?Java CheckedOutputStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.CheckedOutputStream的用法示例。


在下文中一共展示了CheckedOutputStream.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encode

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public void encode(OutputStream out) throws IOException {
    java.util.zip.CRC32 crc32 = new java.util.zip.CRC32();
    CheckedOutputStream outChecked = new CheckedOutputStream(out, crc32);

    // Index Indicator
    outChecked.write(0x00);

    // Number of Records
    EncoderUtil.encodeVLI(outChecked, recordCount);

    // List of Records
    for (IndexRecord record : records) {
        EncoderUtil.encodeVLI(outChecked, record.unpadded);
        EncoderUtil.encodeVLI(outChecked, record.uncompressed);
    }

    // Index Padding
    for (int i = getIndexPaddingSize(); i > 0; --i)
        outChecked.write(0x00);

    // CRC32
    long value = crc32.getValue();
    for (int i = 0; i < 4; ++i)
        out.write((byte)(value >>> (i * 8)));
}
 
开发者ID:dbrant,项目名称:zimdroid,代码行数:26,代码来源:IndexEncoder.java

示例2: createIndexFile

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
private static void createIndexFile(File indexFile, Configuration conf)
    throws IOException {
  if (indexFile.exists()) {
    System.out.println("Deleting existing file");
    indexFile.delete();
  }
  indexFile.createNewFile();
  FSDataOutputStream output = FileSystem.getLocal(conf).getRaw().append(
      new Path(indexFile.getAbsolutePath()));
  Checksum crc = new PureJavaCrc32();
  crc.reset();
  CheckedOutputStream chk = new CheckedOutputStream(output, crc);
  String msg = "Writing new index file. This file will be used only " +
      "for the testing.";
  chk.write(Arrays.copyOf(msg.getBytes(),
      MapTask.MAP_OUTPUT_INDEX_RECORD_LENGTH));
  output.writeLong(chk.getChecksum().getValue());
  output.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestShuffleHandler.java

示例3: createIndexFile

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public static void createIndexFile(File indexFile, Configuration conf)
    throws IOException {
  if (indexFile.exists()) {
    System.out.println("Deleting existing file");
    indexFile.delete();
  }
  indexFile.createNewFile();
  FSDataOutputStream output = FileSystem.getLocal(conf).getRaw().append(
      new Path(indexFile.getAbsolutePath()));
  Checksum crc = new PureJavaCrc32();
  crc.reset();
  CheckedOutputStream chk = new CheckedOutputStream(output, crc);
  String msg = "Writing new index file. This file will be used only " +
      "for the testing.";
  chk.write(Arrays.copyOf(msg.getBytes(),
      MapTask.MAP_OUTPUT_INDEX_RECORD_LENGTH));
  output.writeLong(chk.getChecksum().getValue());
  output.close();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:TestShuffleHandler.java

示例4: encode

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public void encode(OutputStream out) throws IOException {
    java.util.zip.CRC32 crc32 = new java.util.zip.CRC32();
    CheckedOutputStream outChecked = new CheckedOutputStream(out, crc32);

    // Index Indicator
    outChecked.write(0x00);

    // Number of Records
    EncoderUtil.encodeVLI(outChecked, recordCount);

    // List of Records
    for (Iterator i = records.iterator(); i.hasNext(); ) {
        IndexRecord record = (IndexRecord)i.next();
        EncoderUtil.encodeVLI(outChecked, record.unpadded);
        EncoderUtil.encodeVLI(outChecked, record.uncompressed);
    }

    // Index Padding
    for (int i = getIndexPaddingSize(); i > 0; --i)
        outChecked.write(0x00);

    // CRC32
    long value = crc32.getValue();
    for (int i = 0; i < 4; ++i)
        out.write((byte)(value >>> (i * 8)));
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:27,代码来源:IndexEncoder.java

示例5: encode

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public void encode(OutputStream out) throws IOException {
	java.util.zip.CRC32 crc32 = new java.util.zip.CRC32();
	CheckedOutputStream outChecked = new CheckedOutputStream(out, crc32);

	// Index Indicator
	outChecked.write(0x00);

	// Number of Records
	EncoderUtil.encodeVLI(outChecked, recordCount);

	// List of Records
	for (Iterator i = records.iterator(); i.hasNext();) {
		IndexRecord record = (IndexRecord) i.next();
		EncoderUtil.encodeVLI(outChecked, record.unpadded);
		EncoderUtil.encodeVLI(outChecked, record.uncompressed);
	}

	// Index Padding
	for (int i = getIndexPaddingSize(); i > 0; --i)
		outChecked.write(0x00);

	// CRC32
	long value = crc32.getValue();
	for (int i = 0; i < 4; ++i)
		out.write((byte) (value >>> (i * 8)));
}
 
开发者ID:anadon,项目名称:JLS,代码行数:27,代码来源:IndexEncoder.java

示例6: testChecksumStreams

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
@Test
public void testChecksumStreams() throws IOException {
    byte[] content = new byte[33333];
    new Random().nextBytes(content);

    Murmur3F murmur3F = new Murmur3F();
    murmur3F.update(content);
    String hash = murmur3F.getValueHexString();

    murmur3F.reset();
    CheckedOutputStream out = new CheckedOutputStream(new ByteArrayOutputStream(), murmur3F);
    out.write(content);
    Assert.assertEquals(hash, murmur3F.getValueHexString());

    murmur3F.reset();
    CheckedInputStream in = new CheckedInputStream(new ByteArrayInputStream(content), murmur3F);
    IoUtils.readAllBytes(in);
    Assert.assertEquals(hash, murmur3F.getValueHexString());
}
 
开发者ID:greenrobot,项目名称:essentials,代码行数:20,代码来源:ChecksumStreamTest.java


注:本文中的java.util.zip.CheckedOutputStream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。