Here you can find the source of writeStringOrNull(DataOutputStream out, String string)
public static void writeStringOrNull(DataOutputStream out, String string) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2010 IBM Corporation 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 * * Contributors:/* www . j a va 2 s .c o m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.*; public class Main { /** The NULL tag used in bundle storage */ public static final byte NULL = 0; /** The OBJECT tag used in bundle storage */ public static final byte OBJECT = 1; public static void writeStringOrNull(DataOutputStream out, String string) throws IOException { if (string == null) out.writeByte(NULL); else { out.writeByte(OBJECT); out.writeUTF(string); } } }