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


Java DataOutputStream.writeLong方法代码示例

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


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

示例1: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Write the constant to the output stream
 */
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
    if (num instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(num.intValue());
    } else if (num instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(num.longValue());
    } else if (num instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(num.floatValue());
    } else if (num instanceof Double) {
        out.writeByte(CONSTANT_DOUBLE);
        out.writeDouble(num.doubleValue());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:NumberConstantData.java

示例2: setSessionLock

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Creates a session lock file for this process
 */
private void setSessionLock()
{
    try
    {
        File file1 = new File(this.worldDirectory, "session.lock");
        DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file1));

        try
        {
            dataoutputstream.writeLong(this.initializationTime);
        }
        finally
        {
            dataoutputstream.close();
        }
    }
    catch (IOException ioexception)
    {
        ioexception.printStackTrace();
        throw new RuntimeException("Failed to check session lock, aborting");
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:SaveHandler.java

示例3: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream out) throws IOException {
    out.writeInt(VERSION_DROP_TYPE);
    DurableUtils.writeNullableString(out, authority);
    DurableUtils.writeNullableString(out, rootId);
    out.writeInt(flags);
    out.writeInt(icon);
    DurableUtils.writeNullableString(out, title);
    DurableUtils.writeNullableString(out, summary);
    DurableUtils.writeNullableString(out, documentId);
    out.writeLong(availableBytes);
    out.writeLong(totalBytes);
    DurableUtils.writeNullableString(out, mimeTypes);
    DurableUtils.writeNullableString(out, path);
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:16,代码来源:RootInfo.java

示例4: save

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void save(DataOutputStream out) throws IOException
{
    out.writeInt(midi);
    out.writeLong(start);
    out.writeLong(end);
}
 
开发者ID:SmashMaster,项目名称:KraftigAudio,代码行数:8,代码来源:Note.java

示例5: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Write matrix meta to output stream
 * @param output output stream
 * @throws IOException
 */
public void write(DataOutputStream output) throws IOException {
  output.writeInt(matrixId);
  output.writeUTF(matrixName);
  output.writeInt(rowType);
  output.writeInt(row);
  output.writeLong(col);
  output.writeInt(blockRow);
  output.writeLong(blockCol);
  if (options == null || options.isEmpty()) {
    output.writeInt(0);
  } else {
    output.writeInt(options.size());
    for (Map.Entry<String, String> opEntry : options.entrySet()) {
      output.writeUTF(opEntry.getKey());
      output.writeUTF(opEntry.getValue());
    }
  }

  if (partMetas == null || partMetas.isEmpty()) {
    output.writeInt(0);
  } else {
    output.writeInt(partMetas.size());
    for (Map.Entry<Integer, ModelPartitionMeta> partEntry : partMetas.entrySet()) {
      partEntry.getValue().write(output);
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:33,代码来源:ModelFilesMeta.java

示例6: engineStore

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void engineStore(OutputStream out, char[] passwd)
    throws IOException, NoSuchAlgorithmException, CertificateException
{
    MessageDigest md = MessageDigest.getInstance("SHA1");
    md.update(charsToBytes(passwd));
    md.update("Mighty Aphrodite".getBytes("UTF-8"));
    DataOutputStream dout = new DataOutputStream(new DigestOutputStream(out, md));
    dout.writeInt(MAGIC);
    dout.writeInt(2);
    dout.writeInt(aliases.size());
    for (Enumeration e = aliases.elements(); e.hasMoreElements(); )
    {
        String alias = (String) e.nextElement();
        if (trustedCerts.containsKey(alias))
        {
            dout.writeInt(TRUSTED_CERT);
            dout.writeUTF(alias);
            dout.writeLong(((Date) dates.get(alias)).getTime());
            writeCert(dout, (Certificate) trustedCerts.get(alias));
        }
        else
        {
            dout.writeInt(PRIVATE_KEY);
            dout.writeUTF(alias);
            dout.writeLong(((Date) dates.get(alias)).getTime());
            byte[] key = (byte[]) privateKeys.get(alias);
            dout.writeInt(key.length);
            dout.write(key);
            Certificate[] chain = (Certificate[]) certChains.get(alias);
            dout.writeInt(chain.length);
            for (int i = 0; i < chain.length; i++)
                writeCert(dout, chain[i]);
        }
    }
    byte[] digest = md.digest();
    dout.write(digest);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:38,代码来源:JKS.java

示例7: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream out) throws IOException {
    out.writeInt(VERSION_SPLIT_URI);
    DurableUtils.writeNullableString(out, authority);
    DurableUtils.writeNullableString(out, documentId);
    DurableUtils.writeNullableString(out, mimeType);
    DurableUtils.writeNullableString(out, displayName);
    out.writeLong(lastModified);
    out.writeInt(flags);
    DurableUtils.writeNullableString(out, summary);
    out.writeLong(size);
    out.writeInt(icon);
    DurableUtils.writeNullableString(out, path);
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:15,代码来源:DocumentInfo.java

示例8: serialize

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public byte[] serialize(String topic, Trade trade) {
    DataOutputStream out = new DataOutputStream(outStream);
    try {
        out.writeUTF(trade.getTicker());
        out.writeLong(trade.getTime());
        out.writeInt(trade.getPrice());
        out.writeInt(trade.getQuantity());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    byte[] bytes = outStream.toByteArray();
    outStream.reset();
    return bytes;
}
 
开发者ID:hazelcast,项目名称:big-data-benchmark,代码行数:16,代码来源:TradeSerializer.java

示例9: save

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void save(DataOutputStream out) throws IOException {
	out.writeInt(CURRENT_VERSION);

	out.writeInt(this.guilds.size());
	for (String g : this.guilds)
		out.writeUTF(g);

	out.writeInt(this.players.size());
	for (UUID p : this.players) {
		out.writeLong(p.getMostSignificantBits());
		out.writeLong(p.getLeastSignificantBits());
	}
}
 
开发者ID:Yeregorix,项目名称:EpiStats,代码行数:14,代码来源:ObjectList.java

示例10: send

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void send(DataOutputStream out) throws IOException {
    byte[] packetId = VarData.getVarInt(0x1F);

    VarData.writeVarInt(out, 8 + packetId.length);
    out.write(packetId);
    out.writeLong(System.currentTimeMillis());
}
 
开发者ID:Clout-Team,项目名称:JarCraftinator,代码行数:9,代码来源:PacketPlayOutKeepAlive.java

示例11: buildTokenData

import java.io.DataOutputStream; //导入方法依赖的package包/类
private byte[] buildTokenData(MRDelegationTokenIdentifier tokenId,
    Long renewDate) throws IOException {
  ByteArrayOutputStream memStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(memStream);
  try {
    tokenId.write(dataStream);
    dataStream.writeLong(renewDate);
    dataStream.close();
    dataStream = null;
  } finally {
    IOUtils.cleanup(LOG, dataStream);
  }
  return memStream.toByteArray();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:HistoryServerFileSystemStateStoreService.java

示例12: addOrUpdateToken

import java.io.DataOutputStream; //导入方法依赖的package包/类
private void addOrUpdateToken(TokenIdent ident,
    DelegationTokenInformation info, boolean isUpdate) throws Exception {
  String nodeCreatePath =
      getNodePath(ZK_DTSM_TOKENS_ROOT, DELEGATION_TOKEN_PREFIX
          + ident.getSequenceNumber());
  ByteArrayOutputStream tokenOs = new ByteArrayOutputStream();
  DataOutputStream tokenOut = new DataOutputStream(tokenOs);
  ByteArrayOutputStream seqOs = new ByteArrayOutputStream();

  try {
    ident.write(tokenOut);
    tokenOut.writeLong(info.getRenewDate());
    tokenOut.writeInt(info.getPassword().length);
    tokenOut.write(info.getPassword());
    if (LOG.isDebugEnabled()) {
      LOG.debug((isUpdate ? "Updating " : "Storing ")
          + "ZKDTSMDelegationToken_" +
          ident.getSequenceNumber());
    }
    if (isUpdate) {
      zkClient.setData().forPath(nodeCreatePath, tokenOs.toByteArray())
          .setVersion(-1);
    } else {
      zkClient.create().withMode(CreateMode.PERSISTENT)
          .forPath(nodeCreatePath, tokenOs.toByteArray());
    }
  } finally {
    seqOs.close();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:ZKDelegationTokenSecretManager.java

示例13: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Write out the contents of the constant pool, including any additions
 * that have been added.
 */
public void write(DataOutputStream out, Environment env) throws IOException {
    int length = cpool.length;
    if (MoreStuff != null)
        length += MoreStuff.size();
    out.writeShort(length);
    for (int i = 1 ; i < cpool.length; i++) {
        int type = types[i];
        Object x = cpool[i];
        out.writeByte(type);
        switch (type) {
            case CONSTANT_UTF8:
                out.writeUTF((String) x);
                break;
            case CONSTANT_INTEGER:
                out.writeInt(((Number)x).intValue());
                break;
            case CONSTANT_FLOAT:
                out.writeFloat(((Number)x).floatValue());
                break;
            case CONSTANT_LONG:
                out.writeLong(((Number)x).longValue());
                i++;
                break;
            case CONSTANT_DOUBLE:
                out.writeDouble(((Number)x).doubleValue());
                i++;
                break;
            case CONSTANT_CLASS:
            case CONSTANT_STRING:
                out.writeShort(((Number)x).intValue());
                break;
            case CONSTANT_FIELD:
            case CONSTANT_METHOD:
            case CONSTANT_INTERFACEMETHOD:
            case CONSTANT_NAMEANDTYPE: {
                int value = ((Number)x).intValue();
                out.writeShort(value >> 16);
                out.writeShort(value & 0xFFFF);
                break;
            }
            case CONSTANT_METHODHANDLE:
            case CONSTANT_METHODTYPE:
            case CONSTANT_INVOKEDYNAMIC:
                out.write((byte[])x, 0, ((byte[])x).length);
                break;
            default:
                 throw new ClassFormatError("invalid constant type: "
                                               + (int)types[i]);
        }
    }
    for (int i = cpool.length; i < length; i++) {
        String string = (String)(MoreStuff.elementAt(i - cpool.length));
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF(string);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:BinaryConstantPool.java

示例14: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream paramDataOutputStream, ConstantPool paramConstantPool) throws IOException {
    if (null != paramConstantPool) {
        this.constPool = paramConstantPool;
    }
    paramDataOutputStream.writeByte(this.iTag);
    switch (this.iTag) {
        case 7:
            this.iNameIndex = this.constPool.getIndexOf(this.refUTF8);
            paramDataOutputStream.writeShort(this.iNameIndex);
            break;
        case 8:
            this.iStringIndex = this.constPool.getIndexOf(this.refUTF8);
            paramDataOutputStream.writeShort(this.iStringIndex);
            break;
        case 9:
        case 10:
        case 11:
            this.iClassIndex = this.constPool.getIndexOf(this.refClass);
            this.iNameAndTypeIndex = this.constPool.getIndexOf(this.refNameAndType);
            paramDataOutputStream.writeShort(this.iClassIndex);
            paramDataOutputStream.writeShort(this.iNameAndTypeIndex);
            break;
        case 3:
            paramDataOutputStream.writeInt(this.iIntValue);
            break;
        case 4:
            paramDataOutputStream.writeFloat(this.fFloatVal);
            break;
        case 12:
            this.iNameIndex = this.constPool.getIndexOf(this.refUTF8);
            this.iDescriptorIndex = this.constPool.getIndexOf(this.refExtraUTF8);
            paramDataOutputStream.writeShort(this.iNameIndex);
            paramDataOutputStream.writeShort(this.iDescriptorIndex);
            break;
        case 5:
            paramDataOutputStream.writeLong(this.lLongVal);
            break;
        case 6:
            paramDataOutputStream.writeDouble(this.dDoubleVal);
            break;
        case 1:
            paramDataOutputStream.writeUTF(this.sUTFStr);
            break;
        case 2:
        default:
            System.out.println("Unknown constant pool type: " + this.iTag);
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:49,代码来源:ConstantPoolInfo.java

示例15: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream out) throws IOException {
    // current/dead offset ("how long until we die"), highScore
    out.writeLong(TimeUtils.nanoTime() - startTime);
    out.writeInt(highScore);
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:7,代码来源:TimeScorer.java


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