Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { public static void writeString(String s, ByteArrayOutputStream os) throws IOException { os.write(s.getBytes()); os.write(0); //Null terminator } }