Java DataOutputStream Write String writeStringAsBytes(DataOutputStream out, byte[] byteArray)

Here you can find the source of writeStringAsBytes(DataOutputStream out, byte[] byteArray)

Description

Writes string as bytes to data output stream.

License

Open Source License

Parameter

Parameter Description
out a parameter
byteArray a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static final void writeStringAsBytes(DataOutputStream out,
        byte[] byteArray) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Rogue Wave Software, Inc.
 * 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 ww . ja  va 2s  .  c  o m
 *   Rogue Wave Software, Inc. - initial API and implementation
 *******************************************************************************/

import java.io.DataOutputStream;
import java.io.IOException;

public class Main {
    /**
     * Writes string as bytes to data output stream.
     *
     * @param out
     * @param byteArray
     * @throws IOException
     */
    public static final void writeStringAsBytes(DataOutputStream out,
            byte[] byteArray) throws IOException {
        out.writeInt(byteArray.length);
        out.write(byteArray);
    }
}

Related

  1. writeString(String s, DataOutputStream writer)
  2. writeString(String str, DataOutputStream dos)
  3. writeString(String str, DataOutputStream os)
  4. writeString(String stringToWrite, DataOutputStream data)
  5. writeStringAsBytes(DataOutputStream out, byte[] byteArray)
  6. writeStringList(List list, DataOutputStream os)
  7. writeStringOrNull(DataOutputStream out, String string)