Java OutputStream Write Int writeInt(int v, OutputStream stream)

Here you can find the source of writeInt(int v, OutputStream stream)

Description

Writing int to stream

License

Open Source License

Parameter

Parameter Description
v value
stream destination stream

Exception

Parameter Description
IOException an exception

Declaration

public static void writeInt(int v, OutputStream stream) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    /**/*w  w  w  .j  a v a 2  s .com*/
     * Writing int to stream
     *
     * @param v      value
     * @param stream destination stream
     * @throws IOException
     */
    public static void writeInt(int v, OutputStream stream) throws IOException {
        writeByte((byte) ((v >> 24) & 0xFF), stream);
        writeByte((byte) ((v >> 16) & 0xFF), stream);
        writeByte((byte) ((v >> 8) & 0xFF), stream);
        writeByte((byte) (v & 0xFF), stream);
    }

    /**
     * Writing byte to stream
     *
     * @param v      value
     * @param stream destination stream
     * @throws IOException
     */
    public static void writeByte(int v, OutputStream stream) throws IOException {
        stream.write(v);
    }

    /**
     * Writing byte to stream
     *
     * @param v      value
     * @param stream destination stream
     * @throws IOException
     */
    public static void writeByte(byte v, OutputStream stream) throws IOException {
        stream.write(v);
    }
}

Related

  1. writeInt(final OutputStream out, final int v)
  2. writeInt(final OutputStream out, final int value)
  3. writeInt(final OutputStream outputStream, final int integer)
  4. writeInt(int data, int length, OutputStream out)
  5. writeInt(int v, OutputStream stream)
  6. writeInt(OutputStream buffer, int val)
  7. writeInt(OutputStream buffer, int value)
  8. writeInt(OutputStream dest, int val)
  9. writeInt(OutputStream file, int value)