Java DataOutput Write Byte Array writeBytesWithLength(DataOutput out, byte[] bytes)

Here you can find the source of writeBytesWithLength(DataOutput out, byte[] bytes)

Description

write Bytes With Length

License

Open Source License

Declaration

public static void writeBytesWithLength(DataOutput out, byte[] bytes) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005-2008 Polarion Software.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w  w  w . ja  va  2s .co  m*/
 *    Igor Burilo - Initial API and implementation
 *******************************************************************************/

import java.io.DataOutput;
import java.io.IOException;

public class Main {
    public static void writeBytesWithLength(DataOutput out, byte[] bytes) throws IOException {
        out.writeInt(bytes.length);
        if (bytes.length > 0) {
            out.write(bytes);
        }
    }
}

Related

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