• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataOutput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.io.DataOutput的典型用法代码示例。如果您正苦于以下问题:Java DataOutput类的具体用法?Java DataOutput怎么用?Java DataOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: write

import java.io.DataOutput; //导入依赖的package包/类
/**
 * Write the actual data contents of the tag, implemented in NBT extension classes
 */
void write(DataOutput output) throws IOException
{
    if (!this.tagList.isEmpty())
    {
        this.tagType = ((NBTBase)this.tagList.get(0)).getId();
    }
    else
    {
        this.tagType = 0;
    }

    output.writeByte(this.tagType);
    output.writeInt(this.tagList.size());

    for (int i = 0; i < this.tagList.size(); ++i)
    {
        ((NBTBase)this.tagList.get(i)).write(output);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:NBTTagList.java


示例2: write

import java.io.DataOutput; //导入依赖的package包/类
/**
 * FileSystemGroup ::= #scheme (scheme #counter (key value)*)*
 */
@Override
public void write(DataOutput out) throws IOException {
  WritableUtils.writeVInt(out, map.size()); // #scheme
  for (Map.Entry<String, Object[]> entry : map.entrySet()) {
    WritableUtils.writeString(out, entry.getKey()); // scheme
    // #counter for the above scheme
    WritableUtils.writeVInt(out, numSetCounters(entry.getValue()));
    for (Object counter : entry.getValue()) {
      if (counter == null) continue;
      @SuppressWarnings("unchecked")
      FSCounter c = (FSCounter) ((Counter)counter).getUnderlyingCounter();
      WritableUtils.writeVInt(out, c.key.ordinal());  // key
      WritableUtils.writeVLong(out, c.getValue());    // value
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FileSystemCounterGroup.java


示例3: write

import java.io.DataOutput; //导入依赖的package包/类
@Override
public void write(DataOutput out) throws IOException {
  super.write(out);
  WritableUtils.writeVInt(out, id);
  WritableUtils.writeVInt(out, maps);
  WritableUtils.writeVLong(out, inputRecords);
  WritableUtils.writeVLong(out, outputBytes);
  WritableUtils.writeVLong(out, outputRecords);
  WritableUtils.writeVLong(out, maxMemory);
  WritableUtils.writeVInt(out, reduces);
  for (int i = 0; i < reduces; ++i) {
    out.writeDouble(reduceBytes[i]);
    out.writeDouble(reduceRecords[i]);
  }
  WritableUtils.writeVInt(out, nSpec);
  for (int i = 0; i < nSpec; ++i) {
    WritableUtils.writeVLong(out, reduceOutputBytes[i]);
    WritableUtils.writeVLong(out, reduceOutputRecords[i]);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:GridmixSplit.java


示例4: produceRelativePath

import java.io.DataOutput; //导入依赖的package包/类
private static void produceRelativePath(String path, Object out) throws IOException {
    if (path.isEmpty()) {
        if (out instanceof DataOutput) {
            DataOutput dos = (DataOutput)out;
            dos.writeUTF(path);
        }
        return;
    }
    if (testWritePath(path, System.getProperty("netbeans.user"), "user", out)) { // NOI18N
        return;
    }
    int cnt = 0;
    for (String p : Clusters.dirs()) {
        if (testWritePath(path, p, "" + cnt, out)) {
            return;
        }
        cnt++;
    }
    if (testWritePath(path, System.getProperty("netbeans.home"), "home", out)) { // NOI18N
        return;
    }
    LOG.log(Level.FINE, "Cannot find relative path for {0}", path); // NOI18N
    doWritePath("abs", path, out); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Stamps.java


示例5: writeStringArray

import java.io.DataOutput; //导入依赖的package包/类
/**
 * Writes an array of <code>String</code>s to a <code>DataOutput</code>. This method will
 * serialize a <code>null</code> array and not throw a <code>NullPointerException</code>.
 *
 * @throws IOException A problem occurs while writing to <code>out</code>
 *
 * @see #readStringArray
 * @see #writeString
 */
public static void writeStringArray(String[] array, DataOutput out) throws IOException {

  InternalDataSerializer.checkOut(out);

  int length;
  if (array == null) {
    length = -1;
  } else {
    length = array.length;
  }
  InternalDataSerializer.writeArrayLength(length, out);
  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Writing String array of length {}", length);
  }
  if (length > 0) {
    for (int i = 0; i < length; i++) {
      writeString(array[i], out);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:30,代码来源:DataSerializer.java


示例6: readWrite

import java.io.DataOutput; //导入依赖的package包/类
private int readWrite(ProgressWindow progress, DataOutput out, int size, byte[] buffer) {
    if (size == 0)
        return 0;
    try {
        in.readFully(buffer, 0, size);
        if (size != BUFFERSIZE)
            progress.setText("Finishing up the transfer..");
        out.write(buffer, 0, size);
    } catch (Exception ex) {
        progress.setText("Transmission error!");
        System.out.println("Transmission error");
        return -1;
    }

    bytesSent += size;
    progress.setText("Transfered: " + Util.getStringFromBytes(bytesSent),
            FileProgressWindow.BAR_1);
    progress.setValue(bytesSent + amountToSkip, FileProgressWindow.BAR_1);
    return size;
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:21,代码来源:DownloaderThread.java


示例7: writeStrings

import java.io.DataOutput; //导入依赖的package包/类
private int writeStrings(DataOutput payload, ByteBuffer offsets, boolean shrink) throws IOException {
    int stringOffset = 0;
    Map<String, Integer> used = new HashMap<>();  // Keeps track of strings already written
    for (String string : strings) {
        // Dedupe everything except stylized strings, unless shrink is true (then dedupe everything)
        if (used.containsKey(string) && (shrink || isOriginalDeduped)) {
            Integer offset = used.get(string);
            offsets.putInt(offset == null ? 0 : offset);
        } else {
            byte[] encodedString = ResourceString.encodeString(string, getStringType());
            payload.write(encodedString);
            used.put(string, stringOffset);
            offsets.putInt(stringOffset);
            stringOffset += encodedString.length;
        }
    }

    // ARSC files pad to a 4-byte boundary. We should do so too.
    stringOffset = writePad(payload, stringOffset);
    return stringOffset;
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:22,代码来源:StringPoolChunk.java


示例8: saveINodeDiffs

import java.io.DataOutput; //导入依赖的package包/类
/**
 * Save SnapshotDiff list for an INodeDirectoryWithSnapshot.
 * @param sNode The directory that the SnapshotDiff list belongs to.
 * @param out The {@link DataOutput} to write.
 */
private static <N extends INode, A extends INodeAttributes, D extends AbstractINodeDiff<N, A, D>>
    void saveINodeDiffs(final AbstractINodeDiffList<N, A, D> diffs,
    final DataOutput out, ReferenceMap referenceMap) throws IOException {
  // Record the diffs in reversed order, so that we can find the correct
  // reference for INodes in the created list when loading the FSImage
  if (diffs == null) {
    out.writeInt(-1); // no diffs
  } else {
    final List<D> list = diffs.asList();
    final int size = list.size();
    out.writeInt(size);
    for (int i = size - 1; i >= 0; i--) {
      list.get(i).write(out, referenceMap);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:SnapshotFSImageFormat.java


示例9: testBlackListInfo

import java.io.DataOutput; //导入依赖的package包/类
/**
 * test BlackListInfo class
 * 
 * @throws IOException
 */
@Test (timeout=5000)
public void testBlackListInfo() throws IOException {
  BlackListInfo info = new BlackListInfo();
  info.setBlackListReport("blackListInfo");
  info.setReasonForBlackListing("reasonForBlackListing");
  info.setTrackerName("trackerName");
  ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  DataOutput out = new DataOutputStream(byteOut);
  info.write(out);
  BlackListInfo info2 = new BlackListInfo();
  info2.readFields(new DataInputStream(new ByteArrayInputStream(byteOut
      .toByteArray())));
  assertEquals(info, info);
  assertEquals(info.toString(), info.toString());
  assertEquals(info.getTrackerName(), "trackerName");
  assertEquals(info.getReasonForBlackListing(), "reasonForBlackListing");
  assertEquals(info.getBlackListReport(), "blackListInfo");

}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestNetworkedJob.java


示例10: write

import java.io.DataOutput; //导入依赖的package包/类
@Override
public void write(DataOutput out) throws IOException {
  super.write(out);
  
  // Write out the number of entries in the map
  
  out.writeInt(instance.size());
  
  // Then write out each key/value pair
  
  for (Map.Entry<WritableComparable, Writable> e: instance.entrySet()) {
    out.writeByte(getId(e.getKey().getClass()));
    e.getKey().write(out);
    out.writeByte(getId(e.getValue().getClass()));
    e.getValue().write(out);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:SortedMapWritable.java


示例11: toData

import java.io.DataOutput; //导入依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
  out.writeBoolean(isRequestForEntireConfiguration);
  int size = groups.size();
  out.writeInt(size);
  if (size > 0) {
    for (String group : groups) {
      out.writeUTF(group);
    }
  }
  out.writeInt(numAttempts);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:ConfigurationRequest.java


示例12: NbtFactory

import java.io.DataOutput; //导入依赖的package包/类
/**
 * Construct an instance of the NBT factory by deducing the class of NBTBase.
 */
private NbtFactory() {
    if (BASE_CLASS == null) {
        try {
            // Keep in mind that I do use hard-coded field names - but it's okay as long as we're dealing
            // with CraftBukkit or its derivatives. This does not work in MCPC+ however.
            ClassLoader loader = NbtFactory.class.getClassLoader();

            String packageName = getPackageName();
            Class<?> offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer");

            // Prepare NBT
            COMPOUND_CLASS = getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType();
            BASE_CLASS = COMPOUND_CLASS.getSuperclass();
            NBT_GET_TYPE = getMethod(0, Modifier.STATIC, BASE_CLASS, "getTypeId");
            NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, BASE_CLASS, "createTag", byte.class);

            // Prepare CraftItemStack
            CRAFT_STACK = loader.loadClass(packageName + ".inventory.CraftItemStack");
            CRAFT_HANDLE = getField(null, CRAFT_STACK, "handle");
            STACK_TAG = getField(null, CRAFT_HANDLE.getType(), "tag");

            // Loading/saving
            String nmsPackage = BASE_CLASS.getPackage().getName();
            initializeNMS(loader, nmsPackage);

            LOAD_COMPOUND = READ_LIMITER_CLASS != null ?
                    new LoadMethodSkinUpdate(STREAM_TOOLS, READ_LIMITER_CLASS) :
                    new LoadMethodWorldUpdate(STREAM_TOOLS);
            SAVE_COMPOUND = getMethod(Modifier.STATIC, 0, STREAM_TOOLS, null, BASE_CLASS, DataOutput.class);

        } catch (ClassNotFoundException e) {
            throw new IllegalStateException("Unable to find offline player.", e);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:39,代码来源:NbtFactory.java


示例13: writePayload

import java.io.DataOutput; //导入依赖的package包/类
@Override
protected void writePayload(DataOutput output, ByteBuffer header, boolean shrink)
    throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteBuffer offsets = ByteBuffer.allocate(getOffsetSize()).order(ByteOrder.LITTLE_ENDIAN);
  try (LittleEndianDataOutputStream payload = new LittleEndianDataOutputStream(baos)) {
    writeEntries(payload, offsets, shrink);
  }
  output.write(offsets.array());
  output.write(baos.toByteArray());
}
 
开发者ID:madisp,项目名称:android-chunk-utils,代码行数:12,代码来源:TypeChunk.java


示例14: writeBloom

import java.io.DataOutput; //导入依赖的package包/类
/**
 * Writes just the bloom filter to the output array
 * @param out OutputStream to place bloom
 * @throws IOException Error writing bloom array
 */
public void writeBloom(final DataOutput out) throws IOException {
  if (!this.bloom.hasArray()) {
    throw new IOException("Only writes ByteBuffer with underlying array.");
  }
  out.write(bloom.array(), bloom.arrayOffset(), bloom.limit());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:ByteBloomFilter.java


示例15: toData

import java.io.DataOutput; //导入依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);
  DataSerializer.writeObject(this.eventID, out);
  DataSerializer.writePrimitiveInt(this.serialNum, out);
  DataSerializer.writePrimitiveBoolean(this.notifyOfRegionDeparture, out);
  DataSerializer.writeHashMap(this.subregionSerialNumbers, out);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:DestroyRegionOperation.java


示例16: writePayload

import java.io.DataOutput; //导入依赖的package包/类
@Override
protected void writePayload(DataOutput output, ByteBuffer header, boolean shrink) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ByteBuffer offsets = ByteBuffer.allocate(getOffsetSize()).order(ByteOrder.LITTLE_ENDIAN);
    try (LittleEndianDataOutputStream payload = new LittleEndianDataOutputStream(baos)) {
        writeEntries(payload, offsets, shrink);
    }
    output.write(offsets.array());
    output.write(baos.toByteArray());
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:11,代码来源:TypeChunk.java


示例17: toData

import java.io.DataOutput; //导入依赖的package包/类
public void toData(DataOutput out) throws IOException {
  DataSerializer.writeString(this.fieldName, out);
  out.writeInt(this.fieldIndex);
  out.writeInt(this.varLenFieldSeqId);
  DataSerializer.writeEnum(this.type, out);
  out.writeInt(this.relativeOffset);
  out.writeInt(this.vlfOffsetIndex);
  {
    // pre 8.1 we wrote a single boolean
    // 8.1 and after we write a byte whose bits are:
    // 1: identityField
    // 2: deleted
    byte bits = 0;
    if (this.identityField) {
      bits |= IDENTITY_BIT;
    }
    // Note that this code attempts to only set the DELETED_BIT
    // if serializing for 8.1 or later.
    // But in some cases 8.1 serialized data may be sent to a pre 8.1 member.
    // In that case if this bit is set it will cause the pre 8.1 member
    // to set identityField to true.
    // For this reason the pdx delete-field command should only be used after
    // all member have been upgraded to 8.1 or later.
    Version sourceVersion = InternalDataSerializer.getVersionForDataStream(out);
    if (sourceVersion.compareTo(Version.GFE_81) >= 0) {
      if (this.deleted) {
        bits |= DELETED_BIT;
      }
    }
    out.writeByte(bits);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:33,代码来源:PdxField.java


示例18: toData

import java.io.DataOutput; //导入依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
  super.toData(out);
  out.writeInt(this.bucketId);
  out.writeBoolean(this.isRebalance);
  out.writeBoolean(this.replaceOfflineData);
  out.writeBoolean(this.moveSource != null);
  if (this.moveSource != null) {
    InternalDataSerializer.invokeToData(this.moveSource, out);
  }
  out.writeBoolean(this.forceCreation);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:ManageBackupBucketMessage.java


示例19: testSendUnreliably

import java.io.DataOutput; //导入依赖的package包/类
@Test
public void testSendUnreliably() throws Exception {
  for (int i = 0; i < 2; i++) {
    boolean enableMcast = (i == 1);
    initMocks(enableMcast);
    InternalDistributedMember mbr = createAddress(8888);
    DistributedCacheOperation.CacheOperationMessage msg =
        mock(DistributedCacheOperation.CacheOperationMessage.class);
    when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] {mbr});
    when(msg.getMulticast()).thenReturn(enableMcast);
    if (!enableMcast) {
      // for non-mcast we send a message with a reply-processor
      when(msg.getProcessorId()).thenReturn(1234);
    } else {
      // for mcast we send a direct-ack message and expect the messenger
      // to register it
      stub(msg.isDirectAck()).toReturn(true);
    }
    when(msg.getDSFID()).thenReturn((int) DataSerializableFixedID.PUT_ALL_MESSAGE);
    interceptor.collectMessages = true;
    try {
      messenger.sendUnreliably(msg);
    } catch (GemFireIOException e) {
      fail("expected success");
    }
    if (enableMcast) {
      verify(msg, atLeastOnce()).registerProcessor();
    }
    verify(msg).toData(isA(DataOutput.class));
    assertTrue("expected 1 message but found " + interceptor.collectedMessages,
        interceptor.collectedMessages.size() == 1);
    assertTrue(interceptor.collectedMessages.get(0).isFlagSet(Message.Flag.NO_RELIABILITY));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:35,代码来源:JGroupsMessengerJUnitTest.java


示例20: toDataPre_GFE_8_0_0_0

import java.io.DataOutput; //导入依赖的package包/类
public void toDataPre_GFE_8_0_0_0(DataOutput out) throws IOException {
  super.toData(out);
  DataSerializer.writeString(Id, out);
  out.writeLong(startTime);
  out.writeInt(remoteDSId);
  out.writeBoolean(isRunning);
  out.writeBoolean(isPrimary);
  out.writeBoolean(isParallel);
  out.writeBoolean(isBatchConflationEnabled);
  out.writeBoolean(isPersistenceEnabled);
  out.writeInt(alertThreshold);
  out.writeBoolean(manualStart);
  DataSerializer.writeArrayList(eventFiltersClassNames, out);
  DataSerializer.writeArrayList(transFiltersClassNames, out);
  DataSerializer.writeArrayList(senderEventListenerClassNames, out);
  out.writeBoolean(isDiskSynchronous);
  // out.writeInt(dispatcherThreads);
  if (isParallel)
    out.writeInt(1);// it was 1 on previous version of gemfire
  else if (orderPolicy == null)
    out.writeInt(1);// it was 1 on previous version of gemfire
  else
    out.writeInt(dispatcherThreads);

  if (isParallel)
    DataSerializer.writeObject(null, out);
  else
    DataSerializer.writeObject(orderPolicy, out);

  boolean serverLocationFound = (this.serverLocation != null);
  DataSerializer.writePrimitiveBoolean(serverLocationFound, out);
  if (serverLocationFound) {
    InternalDataSerializer.invokeToData(serverLocation, out);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:36,代码来源:GatewaySenderAdvisor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Key类代码示例发布时间:2022-05-20
下一篇:
Java AbstractTableModel类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap