Java DataOutput Write String writeString(DataOutput dout, String value)

Here you can find the source of writeString(DataOutput dout, String value)

Description

Writes a string.

License

Open Source License

Parameter

Parameter Description
dout - the output to write to.
value - the string to write

Exception

Parameter Description
IOException - if there is an exception thrown fromDataOutput.writeUTF().

Declaration

public static void writeString(DataOutput dout, String value) throws IOException 

Method Source Code


//package com.java2s;

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

public class Main {
    /**/*from  w  w  w.  j  a v a2s  .co  m*/
     * The empty string.
     */
    static final String EMPTY_STRING = "";

    /**
     * Writes a string. If the string is null, EMPTY_STRING is written. Uses
     * DataOutput.writeUTF() for the write.
     *
     * @param dout - the output to write to. 
     * @param value - the string to write
     * @throws IOException - if there is an exception thrown from
     * DataOutput.writeUTF().
     * @see DataOutput#writeUTF(String)
     */
    public static void writeString(DataOutput dout, String value) throws IOException {
        if (value == null) {
            dout.writeUTF(EMPTY_STRING);
        } else {
            dout.writeUTF(value);
        }
    }
}

Related

  1. writeString(DataOutput out, String s)
  2. writeString(DataOutput out, String s)
  3. writeString(DataOutput out, String s)
  4. writeString(DataOutput out, String v)