Here you can find the source of writeString(DataOutputStream out, String s)
public static final void writeString(DataOutputStream out, String s) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.io.DataOutputStream; import java.io.IOException; public class Main { public static final void writeString(DataOutputStream out, String s) throws IOException { boolean isNull = s == null; out.writeBoolean(isNull);/*from w ww .j a va2s . com*/ if (!isNull) { out.writeUTF(s); } } }