Java DataOutput Write Byte Array writeBytes(DataOutputStream out, byte[] data)

Here you can find the source of writeBytes(DataOutputStream out, byte[] data)

Description

Write a byte array.

License

Open Source License

Parameter

Parameter Description
data the value

Return

itself

Declaration

public static void writeBytes(DataOutputStream out, byte[] data) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    /**/*from  w  ww  . j  a  va 2  s  .co m*/
     * Write a byte array.
     *
     * @param data the value
     * @return itself
     */
    public static void writeBytes(DataOutputStream out, byte[] data) throws IOException {
        if (data == null) {
            out.writeInt(-1);
        } else {
            out.writeInt(data.length);
            out.write(data);
        }
    }
}

Related

  1. writeBytes(byte[] data, DataOutput out)
  2. writeBytes(DataOutput dataOutput, byte[] bytes)
  3. writeBytesToSocket(InputStream requestData, DataOutputStream writeClient)
  4. writeBytesWithLength(DataOutput out, byte[] bytes)