Here you can find the source of writeString(String s, OutputStream out)
public static void writeString(String s, OutputStream out) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.OutputStream; public class Main { public static void writeString(String s, OutputStream out) throws IOException { if (s == null) { writeInt(0, out);//from w w w . ja v a 2 s. c o m return; } int len = s.length(); writeInt(len, out); for (int i = 0; i < len; i++) writChar(s.charAt(i), out); } public static void writeInt(int val, OutputStream out) throws IOException { out.write((val >>> 24) & 0xff); out.write((val >>> 16) & 0xff); out.write((val >>> 8) & 0xff); out.write(val & 0xff); } public static void writChar(char val, OutputStream out) throws IOException { out.write((val >>> 8) & 0xff); out.write(val & 0xff); } }