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

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

Description

Write the given int in little endian format as 4 bytes

License

Open Source License

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.IOException;

import java.io.OutputStream;

public class Main {
    /**/*  ww  w.  j  av a  2s  . co  m*/
     * Write the given int in little endian format as 4 bytes
     */
    public static void writeInt(int v, OutputStream stream) throws IOException {
        writeByte((byte) (v & 0xFF), stream);
        writeByte((byte) ((v >> 8) & 0xFF), stream);
        writeByte((byte) ((v >> 16) & 0xFF), stream);
        writeByte((byte) ((v >> 24) & 0xFF), stream);
    }

    public static void writeByte(int v, OutputStream stream) throws IOException {
        stream.write(v);
    }

    public static void writeByte(byte v, OutputStream stream) throws IOException {
        stream.write(v);
    }
}

Related

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