Here you can find the source of writeBytesWithLength(DataOutput out, byte[] bytes)
public static void writeBytesWithLength(DataOutput out, byte[] bytes) throws IOException
//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); } } }