Here you can find the source of writeString(DataOutputStream out, String str)
Parameter | Description |
---|---|
out | DataOutputStream to write to. |
str | The string to write. |
Parameter | Description |
---|---|
IOException | if an I/O error occurs. |
public static void writeString(DataOutputStream out, String str) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.DataOutputStream; import java.io.IOException; public class Main { /**//from ww w . j a v a2 s. c o m * Writes a string to a DataInputStream. * @param out DataOutputStream to write to. * @param str The string to write. * @throws IOException if an I/O error occurs. */ public static void writeString(DataOutputStream out, String str) throws IOException { out.writeShort(str.length()); for (char letter : str.toCharArray()) { out.writeChar(letter); } } }