Here you can find the source of writeStringAsBytes(DataOutputStream out, byte[] byteArray)
public static void writeStringAsBytes(DataOutputStream out, byte[] byteArray) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2007 IBM Corporation and others. * 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:// ww w.j a v a2 s. c om * Zend and IBM - Initial implementation *******************************************************************************/ import java.io.DataOutputStream; import java.io.IOException; public class Main { public static void writeStringAsBytes(DataOutputStream out, byte[] byteArray) throws IOException { out.writeInt(byteArray.length); out.write(byteArray); } }