Here you can find the source of writeString(String s, DataOutputStream out)
public static void writeString(String s, DataOutputStream out) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void writeString(String s, DataOutputStream out) throws IOException { out.writeInt(s.length());//from ww w . j av a 2 s . c om for (char c : s.toCharArray()) { out.writeChar(c); } } }