Example usage for java.io OutputStream write

List of usage examples for java.io OutputStream write

Introduction

In this page you can find the example usage for java.io OutputStream write.

Prototype

public void write(byte b[]) throws IOException 

Source Link

Document

Writes b.length bytes from the specified byte array to this output stream.

Usage

From source file:Main.java

public static void writeUnsignedInt32(OutputStream out, int value) throws IOException {
    out.write((byte) (value >>> 24));
    out.write((byte) (value >>> 16));
    out.write((byte) (value >>> 8));
    out.write((byte) value);
}

From source file:Main.java

public static void writeUnsignedInt32LittleEndian(OutputStream out, int value) throws IOException {
    out.write((byte) value);
    out.write((byte) (value >>> 8));
    out.write((byte) (value >>> 16));
    out.write((byte) (value >>> 24));
}

From source file:Main.java

public static void writeLong(OutputStream os, long n) throws IOException {
    os.write((byte) (n >>> 0));
    os.write((byte) (n >>> 8));
    os.write((byte) (n >>> 16));
    os.write((byte) (n >>> 24));
    os.write((byte) (n >>> 32));
    os.write((byte) (n >>> 40));
    os.write((byte) (n >>> 48));
    os.write((byte) (n >>> 56));
}

From source file:Main.java

public static final void Write4(OutputStream out, int v) throws IOException {
    out.write(v & 0xff);
    out.write((v >> 8) & 0xff);
    out.write((v >> 16) & 0xff);
    out.write((v >> 24) & 0xff);
}

From source file:Main.java

public static final void Write2(OutputStream out, int v) throws IOException {
    out.write(v & 0xff);
    out.write((v >> 8) & 0xff);
}

From source file:Main.java

public static void uint32ToStream(long value, OutputStream stream) throws IOException {
    stream.write((byte) (0xFFL & (value >> 0)));
    stream.write((byte) (0xFFL & (value >> 8)));
    stream.write((byte) (0xFFL & (value >> 16)));
    stream.write((byte) (0xFFL & (value >> 24)));
}

From source file:Main.java

public static void print(OutputStream out, String str) throws IOException {
    out.write(str.getBytes("UTF-8")); //$NON-NLS-1$
}

From source file:Main.java

public static void endXmlNode(OutputStream out, String name) throws IOException {
    out.write('<');
    out.write('/');
    print(out, name);/*from   ww  w  .j ava  2 s.co m*/
    out.write('>');
    out.write('\n');
}

From source file:Main.java

public static void uint64ToStream(long value, OutputStream stream) throws IOException {
    stream.write((byte) (0xFFL & (value >> 0)));
    stream.write((byte) (0xFFL & (value >> 8)));
    stream.write((byte) (0xFFL & (value >> 16)));
    stream.write((byte) (0xFFL & (value >> 24)));
    stream.write((byte) (0xFFL & (value >> 32)));
    stream.write((byte) (0xFFL & (value >> 40)));
    stream.write((byte) (0xFFL & (value >> 48)));
    stream.write((byte) (0xFFL & (value >> 56)));
}

From source file:Main.java

/**
 * Write int.//from w  w  w  .j a v a 2s  .c  om
 *
 * @param os the os
 * @param n the n
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void writeInt(OutputStream os, int n) throws IOException {
    os.write((n >> 0) & 0xff);
    os.write((n >> 8) & 0xff);
    os.write((n >> 16) & 0xff);
    os.write((n >> 24) & 0xff);
}