Java OutputStream Write Int writeInt(OutputStream output, int value)

Here you can find the source of writeInt(OutputStream output, int value)

Description

Write int, little endian

License

Open Source License

Parameter

Parameter Description
output a parameter
value a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void writeInt(OutputStream output, int value) throws IOException 

Method Source Code

//package com.java2s;
/**//from ww  w. j a va2  s  . com
 * File: $HeadURL: https://hdt-java.googlecode.com/svn/trunk/hdt-java/src/org/rdfhdt/hdt/util/io/IOUtil.java $
 * Revision: $Rev: 194 $
 * Last modified: $Date: 2013-03-04 21:30:01 +0000 (lun, 04 mar 2013) $
 * Last modified by: $Author: mario.arias $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Contacting the authors:
 *   Mario Arias:               mario.arias@deri.org
 *   Javier D. Fernandez:       jfergar@infor.uva.es
 *   Miguel A. Martinez-Prieto: migumar2@infor.uva.es
 *   Alejandro Andres:          fuzzy.alej@gmail.com
 */

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    /**
     * Write int, little endian
     * @param output
     * @param value
     * @throws IOException
     */
    public static void writeInt(OutputStream output, int value) throws IOException {
        byte[] writeBuffer = new byte[4];
        writeBuffer[0] = (byte) (value & 0xFF);
        writeBuffer[1] = (byte) ((value >> 8) & 0xFF);
        writeBuffer[2] = (byte) ((value >> 16) & 0xFF);
        writeBuffer[3] = (byte) ((value >> 24) & 0xFF);
        output.write(writeBuffer, 0, 4);
    }
}

Related

  1. writeInt(OutputStream out, int value)
  2. writeInt(OutputStream out, int value)
  3. writeInt(OutputStream out, int value)
  4. writeInt(OutputStream out, int x)
  5. writeInt(OutputStream out, int x)
  6. writeInt(OutputStream outputStream, int integerToWrite)
  7. writeInt(OutputStream stream, int value)