本文整理汇总了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());
}
}
示例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");
}
}
示例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);
}
示例4: save
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void save(DataOutputStream out) throws IOException
{
out.writeInt(midi);
out.writeLong(start);
out.writeLong(end);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
}
示例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());
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}