Here you can find the source of writeString(DataOutputStream out, String text)
text
is null.
Parameter | Description |
---|---|
out | the output stream |
text | the text to be emitted |
Parameter | Description |
---|---|
IOException | in case of any I/O error or problem |
public static void writeString(DataOutputStream out, String text) throws IOException
//package com.java2s; //License from project: Apache License import java.io.DataOutputStream; import java.io.IOException; public class Main { /**/*from w w w. jav a2 s .c om*/ * Writes a string to the given output stream and emits an additional short * to transfer if <code>text</code> is <b>null</b>. * * @param out the output stream * @param text the text to be emitted * @throws IOException in case of any I/O error or problem * * @since 1.00 */ public static void writeString(DataOutputStream out, String text) throws IOException { if (null == text) { out.writeShort(0); } else { out.writeShort(1); out.writeUTF(text); } } }