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


Java DataOutputStream.writeInt方法代码示例

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


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

示例1: clientWork

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Writes the seat in the socket and reads the returned student info.
 *
 * @see Client#clientWork(InputStream, OutputStream);
 */
@Override
protected void clientWork(InputStream inputStream, OutputStream outputStream) {
    try {
        DataOutputStream writer = new DataOutputStream(outputStream);
        DataInputStream reader = new DataInputStream(inputStream);

        writer.writeUTF(Constants.TEACHER_TOKEN);
        writer.writeInt(seat);

        int count = reader.readInt();
        byte[] bytes = new byte[count];
        reader.readFully(bytes);

        studentInfo = StudentInfo.deserialize(bytes);

        writer.close();
        reader.close();
    } catch (Exception ignored) {
    }
}
 
开发者ID:theawless,项目名称:Programming-Languages-Lab,代码行数:26,代码来源:TeacherClient.java

示例2: testCopyOnWrite

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Test
public void testCopyOnWrite() throws IOException
{
    ByteArrayOutputStream writeTo = new ByteArrayOutputStream();
    ByteArrayOutputStream copyTo = new ByteArrayOutputStream();
    DataOutputStream copyOnWriteOutputStream = new DataOutputStream(new CopyOnWriteOutputStream(writeTo, copyTo));
    copyOnWriteOutputStream.writeInt(5);
    copyOnWriteOutputStream.writeInt(10);
    copyOnWriteOutputStream.close();
    DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(writeTo.toByteArray()));
    Assert.assertEquals(5L, dataInputStream.readInt());
    Assert.assertEquals(10L, dataInputStream.readInt());
    DataInputStream dataInputStream2 = new DataInputStream(new ByteArrayInputStream(copyTo.toByteArray()));
    Assert.assertEquals(5L, dataInputStream2.readInt());
    Assert.assertEquals(10L, dataInputStream2.readInt());
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:17,代码来源:CopyOnWriteOutputStreamTest.java

示例3: serialize

import java.io.DataOutputStream; //导入方法依赖的package包/类
public static void serialize(final BinSerializable serializable, final OutputStream output)
        throws IOException {
    DataOutputStream out = new DataOutputStream(output);
    try {
        out.write(HEADER);
        out.writeInt(VERSION);
        serializable.write(out);
    } finally {
        try {
            out.close();
        } catch (IOException ignored) { }
    }
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:14,代码来源:BinSerializer.java

示例4: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
protected void write(DataOutputStream outputStream) throws Exception {
    outputStream.writeLong(nextBlock.getPos());
    outputStream.writeInt(largestInNextBlock);
    outputStream.writeInt(entries.size());
    for (FreeListEntry entry : entries) {
        outputStream.writeLong(entry.pos.getPos());
        outputStream.writeInt(entry.size);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:FreeListBlockStore.java

示例5: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream outstr) throws IOException {
    outstr.writeInt(entries.size());
    for (IndexEntry entry : entries) {
        outstr.writeLong(entry.hashCode);
        outstr.writeLong(entry.dataBlock.getPos());
        outstr.writeLong(entry.childIndexBlock.getPos());
    }
    outstr.writeLong(tailPos.getPos());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:BTreePersistentIndexedCache.java

示例6: writeOut

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void writeOut(DataOutputStream out) throws IOException
{
	out.writeInt(desc.data.length);
	for(BrightFeature ft:desc.data)
	{
		out.writeInt(ft.value.length);
		for(double val:ft.value)
		{
			out.writeDouble(val);
		}
	}
	hash.writeOut(out);
}
 
开发者ID:ForOhForError,项目名称:MTG-Card-Recognizer,代码行数:14,代码来源:ImageDesc.java

示例7: JdpPacketWriter

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Create a JDP packet, add mandatory magic and version headers
 *
 * @throws IOException
 */
public JdpPacketWriter()
        throws IOException {
    baos = new ByteArrayOutputStream();
    pkt = new DataOutputStream(baos);

    pkt.writeInt(JdpGenericPacket.getMagic());
    pkt.writeShort(JdpGenericPacket.getVersion());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JdpPacketWriter.java

示例8: dump

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Dump instruction as byte code to stream out.
 * @param out Output stream
 */
@Override
public void dump( final DataOutputStream out ) throws IOException {
    super.setIndex(getTargetOffset());
    out.writeByte(super.getOpcode());
    out.writeInt(super.getIndex());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:JSR_W.java

示例9: save

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void save(DataOutputStream out) throws Exception {
    out.writeUTF(template);
    out.writeInt(offsetList.size());
    for (int[] offset : offsetList) {
        out.writeInt(offset[0]);
        out.writeInt(offset[1]);
    }
    out.writeInt(delimiterList.size());
    for (String s : delimiterList) {
        out.writeUTF(s);
    }
}
 
开发者ID:shibing624,项目名称:crf-seg,代码行数:14,代码来源:FeatureTemplate.java

示例10: wrapWithSasl

import java.io.DataOutputStream; //导入方法依赖的package包/类
private static void wrapWithSasl(ByteArrayOutputStream response, Call call)
    throws IOException {
  if (call.connection.saslServer != null) {
    byte[] token = call.rpcResponse.array();
    // synchronization may be needed since there can be multiple Handler
    // threads using saslServer to wrap responses.
    synchronized (call.connection.saslServer) {
      token = call.connection.saslServer.wrap(token, 0, token.length);
    }
    if (LOG.isDebugEnabled())
      LOG.debug("Adding saslServer wrapped token of size " + token.length
          + " as call response.");
    response.reset();
    // rebuild with sasl header and payload
    RpcResponseHeaderProto saslHeader = RpcResponseHeaderProto.newBuilder()
        .setCallId(AuthProtocol.SASL.callId)
        .setStatus(RpcStatusProto.SUCCESS)
        .build();
    RpcSaslProto saslMessage = RpcSaslProto.newBuilder()
        .setState(SaslState.WRAP)
        .setToken(ByteString.copyFrom(token, 0, token.length))
        .build();
    RpcResponseMessageWrapper saslResponse =
        new RpcResponseMessageWrapper(saslHeader, saslMessage);

    DataOutputStream out = new DataOutputStream(response);
    out.writeInt(saslResponse.getLength());
    saslResponse.write(out);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:Server.java

示例11: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream output) throws IOException {
    output.writeBoolean(getValue().hasDisplayName());
    if(getValue().hasDisplayName()) {
        output.writeUTF(getValue().getDisplayName());
    }
    
    output.writeBoolean(getValue().hasLocalizedName());
    if(getValue().hasLocalizedName()) {
        output.writeUTF(getValue().getLocalizedName());
    }
    
    ArrayListStorage<StringStorage> loreStorage = new ArrayListStorage<StringStorage>(getValue().hasLore() ? getValue().getLore().stream().map(StringStorage::new).collect(Collectors.toList()) : new ArrayList<>());
    loreStorage.write(output);
    
    output.writeInt(getValue().getEnchants().size());
    
    Map<EnchantmentStorage, IntStorage> storages = new HashMap<>();
    getValue().getEnchants().forEach((enchantment, level) -> storages.put(new EnchantmentStorage(enchantment), new IntStorage(level)));
    HashMapStorage<EnchantmentStorage, IntStorage> enchantStorage = new HashMapStorage<EnchantmentStorage, IntStorage>(storages);
    enchantStorage.write(output);
    
    output.writeInt(getValue().getItemFlags().size());
    for(ItemFlag flag : getValue().getItemFlags()) {
        output.writeUTF(flag.toString());
    }
    
    output.writeBoolean(getValue().isUnbreakable());
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:30,代码来源:ItemMetaStorage.java

示例12: writeToStream

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

    out.writeInt(objectsCounts.length);

    for (int i = 0; i < objectsCounts.length; i++) {
        out.writeInt(objectsCounts[i]);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AllocMemoryResultsSnapshot.java

示例13: writeTransportHeader

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Send transport header over stream.
 */
private void writeTransportHeader(DataOutputStream out)
    throws RemoteException
{
    try {
        // write out transport header
        DataOutputStream dataOut =
            new DataOutputStream(out);
        dataOut.writeInt(TransportConstants.Magic);
        dataOut.writeShort(TransportConstants.Version);
    } catch (IOException e) {
        throw new ConnectIOException(
            "error writing JRMP transport header", e);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:TCPChannel.java

示例14: createRowKey

import java.io.DataOutputStream; //导入方法依赖的package包/类
static byte[] createRowKey(int keyPart1, int keyPart2) {
  ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
  DataOutputStream dos = new DataOutputStream(bos);
  try {
    dos.writeInt(keyPart1);
    dos.writeInt(keyPart2);
  } catch (IOException e) {
    // should not happen
    throw new RuntimeException(e);
  }

  return bos.toByteArray();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestRowDataSearchWithPrefix.java

示例15: save

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void save(DataOutputStream out) throws IOException
{
    ArrayList<Vec3> list = new ArrayList<>();
    for (WireNode n = first; n != null; n = n.next) list.add(n.pos);
    
    out.writeInt(list.size());
    for (Vec3 v : list) v.write(out);
}
 
开发者ID:SmashMaster,项目名称:KraftigAudio,代码行数:10,代码来源:Wire.java


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