Here you can find the source of writeString(DataOutputStream out, String theString)
Parameter | Description |
---|---|
theString | the value |
public static void writeString(DataOutputStream out, String theString) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.DataOutputStream; import java.io.IOException; public class Main { /**// w w w . ja v a 2 s.c om * Write a string. The maximum string length is Integer.MAX_VALUE. * * @param theString the value * @return itself */ public static void writeString(DataOutputStream out, String theString) throws IOException { if (theString == null) { out.writeInt(-1); } else { int len = theString.length(); out.writeInt(len); writeCharsOfString(out, theString); } } public static void writeCharsOfString(DataOutputStream out, String theString) throws IOException { int len = theString.length(); for (int i = 0; i < len; i++) { out.writeChar(theString.charAt(i)); } } }