Java Utililty Methods DataOutputStream Write String

List of utility methods to do DataOutputStream Write String

Description

The list of methods to do DataOutputStream Write String are organized into topic(s).

Method

voidwriteString(String stringToWrite, DataOutputStream data)
Writes a String to the DataOutputStream
if (stringToWrite.length() > 32767) {
    throw new IOException("String too big");
} else {
    data.writeShort(stringToWrite.length());
    data.writeChars(stringToWrite);
voidwriteStringAsBytes(DataOutputStream out, byte[] byteArray)
write String As Bytes
out.writeInt(byteArray.length);
out.write(byteArray);
voidwriteStringAsBytes(DataOutputStream out, byte[] byteArray)
Writes string as bytes to data output stream.
out.writeInt(byteArray.length);
out.write(byteArray);
voidwriteStringList(List list, DataOutputStream os)
write String List
if (list == null) {
    os.writeInt(-1);
    return;
os.writeInt(list.size());
for (int k = 0; k < list.size(); k++) {
    writeString(list.get(k), os);
voidwriteStringOrNull(DataOutputStream out, String string)
write String Or Null
if (string == null)
    out.writeByte(NULL);
else {
    out.writeByte(OBJECT);
    out.writeUTF(string);