Java Utililty Methods OutputStream Write Byte Array

List of utility methods to do OutputStream Write Byte Array

Description

The list of methods to do OutputStream Write Byte Array are organized into topic(s).

Method

voidwriteBytes(byte[] data, OutputStream out)
write Bytes
transfer(new ByteArrayInputStream(data), out);
voidwriteBytes(byte[] data, OutputStream out)

Writes a given bytes to a stream.

ByteArrayInputStream in = new ByteArrayInputStream(data);
byte[] buffer = new byte[1024];
for (int n; (n = in.read(buffer)) > 0;) {
    out.write(buffer, 0, n);
voidwriteBytes(byte[] data, OutputStream stream)
Writing byte array to stream
stream.write(data);
voidwriteBytes(int[] data, OutputStream out)
Writes data from the integer array to disk as raw bytes.
byte[] b = new byte[4];
for (int word : data) {
    b[0] = (byte) ((word >>> 24) & 0xFF);
    b[1] = (byte) ((word >>> 16) & 0xFF);
    b[2] = (byte) ((word >>> 8) & 0xFF);
    b[3] = (byte) ((word >>> 0) & 0xFF);
    out.write(b);
voidwriteBytes(OutputStream os, byte[] b)
write Bytes
os.write(b, 0, b.length);
voidwriteBytes(OutputStream os, byte[] b)
write Bytes
os.write(toBytes(b.length));
if (b.length > 0) {
    os.write(b);
os.flush();
voidwriteBytes(OutputStream out, byte[] data)
Write a byte array.
writeVarInt(out, data.length);
out.write(data);
voidwriteBytes(OutputStream output, Object value)
write Bytes
try {
    try (ObjectOutputStream out = new ObjectOutputStream(output)) {
        out.writeObject(value);
} catch (IOException e) {
    throw new RuntimeException(e);
voidwriteBytes(OutputStream outputStream, byte[] data)
write Bytes
assert outputStream != null;
try {
    outputStream.write(data);
} finally {
    outputStream.close();
booleanwriteBytesToStream(byte[] bytes, OutputStream os, boolean printStackTraceOnError)
Write the contents of a byte array to an OutputStream without needing to worry about exceptions.
try {
    os.write(bytes);
    return true;
} catch (IOException e) {
    if (printStackTraceOnError) {
        e.printStackTrace();
    return false;
...