Here you can find the source of writeInt24(OutputStream out, int value)
Parameter | Description |
---|---|
out | The output stream to write to. |
value | The value to write. |
public static int writeInt24(OutputStream out, int value) throws IOException
//package com.java2s; // See LICENSE.txt for license information import java.io.IOException; import java.io.OutputStream; public class Main { /**/* w w w .ja va2 s . c om*/ * Writes a 24 bit integer to specified output stream. * @param out The output stream to write to. * @param value The value to write. * @return The actual number of bytes written. */ public static int writeInt24(OutputStream out, int value) throws IOException { int res = 0; if (out != null) { for (int i = 0, shift = 0; i < 3; i++, shift += 8) { out.write((value >>> shift) & 0xff); res++; } } return res; } }