Here you can find the source of writeInt(OutputStream stream, int value)
public static void writeInt(OutputStream stream, int value) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.OutputStream; public class Main { private final static int MASK = 255; private final static int BITS_IN_BYTE = 8; public static void writeInt(OutputStream stream, int value) throws IOException { for (int i = 0; i < 4; ++i) { stream.write(value & MASK); value >>= BITS_IN_BYTE; }// w w w . j av a 2 s . co m } }