當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。