List of usage examples for java.io DataOutputStream writeInt
public final void writeInt(int v) throws IOException
int
to the underlying output stream as four bytes, high byte first. From source file:ro.bmocanu.trafficproxy.peers.PacketSenderImpl.java
/** * {@inheritDoc}//w w w. jav a 2 s . c o m */ @Override protected void internalRun() { DataOutputStream targetOutputStream = peerChannel.getOutputStream(); Packet packet = packetQueue.poll(); if (packet != null) { try { targetOutputStream.writeInt(packet.getConnectorId()); targetOutputStream.writeInt(packet.getWorkerId()); targetOutputStream.writeInt(packet.getCommand().getCode()); targetOutputStream.writeInt(packet.getContentLength()); targetOutputStream.write(packet.getContent()); targetOutputStream.flush(); } catch (IOException exception) { LOG.error("Missed one packet; command=" + packet.getCommand().name() + ", connectorId=" + packet.getConnectorId(), exception); } } }
From source file:com.igormaznitsa.jhexed.swing.editor.filecontainer.FileContainer.java
public void write(final OutputStream out) throws IOException { final DataOutputStream dout = out instanceof DataOutputStream ? (DataOutputStream) out : new DataOutputStream(out); dout.writeInt(MAGIC); dout.writeShort(FORMAT_VERSION);/*from w w w. j ava2 s . c o m*/ dout.writeShort(this.sections.size()); for (final FileContainerSection s : this.sections) { s.write(dout); } dout.writeInt(MAGIC); dout.flush(); }
From source file:com.igormaznitsa.jhexed.values.HexSVGImageValue.java
@Override public void write(final OutputStream out) throws IOException { out.write(TYPE_SVGIMAGE);// w w w. j a v a 2 s .co m super.write(out); final ByteArrayOutputStream imageDataBuffer = new ByteArrayOutputStream(4096); this.image.write(imageDataBuffer, true); final byte[] imageData = imageDataBuffer.toByteArray(); final DataOutputStream dout = out instanceof DataOutputStream ? (DataOutputStream) out : new DataOutputStream(out); dout.writeInt(imageData.length); dout.write(imageData); }
From source file:org.mrgeo.cmd.mapalgebra.python.PythonGateway.java
private void sendGatewayPort(String callbackHost, int callbackPort, int port) throws IOException { // Communicate the bound port back to the caller via the caller-specified callback port log.info("Sending port number (" + port + ") to pymrgeo running at " + callbackHost + ":" + callbackPort); try (Socket callbackSocket = new Socket(callbackHost, callbackPort)) { DataOutputStream dos = new DataOutputStream(callbackSocket.getOutputStream()); dos.writeInt(port); dos.close();/*from w ww . j a v a 2s. c o m*/ } catch (IOException e) { throw new IOException("Can not establish callback socket", e); } }
From source file:com.facebook.infrastructure.db.CommitLogHeader.java
public void serialize(CommitLogHeader clHeader, DataOutputStream dos) throws IOException { dos.writeInt(clHeader.getBitSet().length); dos.write(clHeader.getBitSet());//from ww w . j a v a 2s .c om int[] positions = clHeader.getPositions(); for (int position : positions) { dos.writeInt(position); } }
From source file:org.jboss.test.kerberos.gss.GSSTestServer.java
/** * Sends STOP ({@link #CMD_STOP}) command to a running server. *//*w ww . j a va2 s . c o m*/ private void stop() { System.out.println("Sending STOP command GSSTestServer."); // Create an unbound socket final Socket socket = new Socket(); try { socket.connect(new InetSocketAddress(InetAddress.getLocalHost(), PORT), SOCKET_TIMEOUT); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); dos.writeInt(CMD_STOP); dos.flush(); System.out.println("STOP command sent."); } catch (IOException e) { e.printStackTrace(); } finally { try { socket.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:net.brtly.monkeyboard.plugin.core.panel.PluginDockableLayout.java
@Override public void writeStream(DataOutputStream out) throws IOException { out.writeUTF(_id); // wirthe plugin id byte[] b = Bundle.toByteArray(_bundle); // write the size in bytes of the Bundle out.writeInt(b.length); out.write(b); // write the Bundle }
From source file:org.apache.cassandra.db.RangeCommand.java
public void serialize(RangeCommand command, DataOutputStream dos) throws IOException { dos.writeUTF(command.table);/*from w w w .j a v a 2s.co m*/ dos.writeUTF(command.columnFamily); dos.writeUTF(command.startWith); dos.writeUTF(command.stopAt); dos.writeInt(command.maxResults); }
From source file:org.apache.tez.examples.TopKDataGen.java
private UserPayload createPayload(long streamOutputFileSize, int extraColumns) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); dos.writeLong(streamOutputFileSize); dos.writeInt(extraColumns); dos.close();/*ww w . j av a 2 s. co m*/ bos.close(); ByteBuffer buffer = ByteBuffer.wrap(bos.toByteArray()); return UserPayload.create(buffer); }
From source file:org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager.java
/** * Store the current state of the SecretManager for persistence * //from w w w.j a va 2 s. co m * @param out Output stream for writing into fsimage. * @throws IOException */ public synchronized void saveSecretManagerState(DataOutputStream out) throws IOException { out.writeInt(currentId); saveAllKeys(out); out.writeInt(delegationTokenSequenceNumber); saveCurrentTokens(out); }