Java ByteArrayOutputStream Write Int writeInt(ByteArrayOutputStream b, int v)

Here you can find the source of writeInt(ByteArrayOutputStream b, int v)

Description

write Int

License

Open Source License

Declaration

public static void writeInt(ByteArrayOutputStream b, int v) 

Method Source Code

//package com.java2s;
/*//from  w  w w.j  a  va  2 s  .  com
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import java.io.ByteArrayOutputStream;

public class Main {
    public static void writeInt(byte[] b, int i, int v) {
        b[i] = (byte) ((v >>> 24) & 0xFF);
        b[i + 1] = (byte) ((v >>> 16) & 0xFF);
        b[i + 2] = (byte) ((v >>> 8) & 0xFF);
        b[i + 3] = (byte) (v & 0xFF);
    }

    public static void writeInt(ByteArrayOutputStream b, int v) {
        b.write((v >>> 24) & 0xFF);
        b.write((v >>> 16) & 0xFF);
        b.write((v >>> 8) & 0xFF);
        b.write(v & 0xFF);
    }
}

Related

  1. writeInt(ByteArrayOutputStream baos, int i)
  2. writeInt(ByteArrayOutputStream out, int val)