Here you can find the source of writeInt(OutputStream out, int value)
Parameter | Description |
---|---|
out | The OutputStream to write the int to |
value | The int to write |
public static void writeInt(OutputStream out, int value) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; public class Main { private static final byte[] buffer = new byte[1024]; /**/*from www . j a v a 2 s. c o m*/ * Write an int. * * @param out The OutputStream to write the int to * @param value The int to write */ public static void writeInt(OutputStream out, int value) throws IOException { out.write(value >> 24); out.write(value >> 16); out.write(value >> 8); out.write(value); } /** * Write a number of bytes * * @param out The OutputStream to write to * @param data The bytes to write * @throws IOException */ public static void write(OutputStream out, byte[] data) throws IOException { out.write(data); } /** * Write a repeated byte value. * * @param out The OutputStream to write to * @param value The value to write * @param count Number of times to write the value */ public static void write(final OutputStream out, final int value, final int count) throws IOException { if (count > buffer.length) { // Fallback for (int i = 0; i < count; i++) { writeByte(out, value); } } else { Arrays.fill(buffer, (byte) value); out.write(buffer, 0, count); } } /** * Write a byte. * * @param out The OutputStream to write the byte to * @param value The byte to write * @throws IOException */ public static void writeByte(OutputStream out, int value) throws IOException { out.write(value); } }