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

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

Description

write Int

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
/*//w  w  w.j a  va  2s. co  m
 * Keystone Development Framework
 * Copyright (C) 2004-2009 Rick Knowles
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License
 * Version 2 as published by the Free Software Foundation.
 *
 * This program 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 General Public License Version 2 for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * Version 2 along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void writeInt(OutputStream out, int value) throws IOException {
        byte[] buf = new byte[4];
        writeIntToBuffer(value, buf, 0);
        out.write(buf);
    }

    public static void writeIntToBuffer(int value, byte[] buffer, int offset) {
        buffer[offset] = (byte) (value >>> 0);
        buffer[offset + 1] = (byte) (value >>> 8);
        buffer[offset + 2] = (byte) (value >>> 16);
        buffer[offset + 3] = (byte) (value >>> 24);
    }
}

Related

  1. writeInt(OutputStream out, int i)
  2. writeInt(OutputStream out, int i)
  3. writeInt(OutputStream out, int v)
  4. writeInt(OutputStream out, int v)
  5. writeInt(OutputStream out, int value)
  6. writeInt(OutputStream out, int value)
  7. writeInt(OutputStream out, int value)
  8. writeInt(OutputStream out, int x)
  9. writeInt(OutputStream out, int x)