Here you can find the source of writeString(DataOutputStream out, String str)
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 { public static void writeString(DataOutputStream out, String str) throws IOException { byte[] b = str.getBytes(); out.writeInt(b.length);/* w w w . j a va 2 s . c om*/ out.write(b); } }