write Unsigned Int to OutputStream - Java java.io

Java examples for java.io:OutputStream

Description

write Unsigned Int to OutputStream

Demo Code


//package com.java2s;
import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void writeUnsignedInt(OutputStream os, long intToWrite)
            throws IOException {
        // //from   w  ww  .  ja  va  2 s .co m
        os.write((int) (intToWrite & 0xff));
        os.write((int) ((intToWrite >> 8) & 0xff));
        os.write((int) ((intToWrite >> 16) & 0xff));
        os.write((int) ((intToWrite >> 24) & 0xff));
    }
}

Related Tutorials