Java Utililty Methods DataOutput Write String

List of utility methods to do DataOutput Write String

Description

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

Method

voidwriteString(DataOutput dout, String value)
Writes a string.
if (value == null) {
    dout.writeUTF(EMPTY_STRING);
} else {
    dout.writeUTF(value);
voidwriteString(DataOutput out, String s)
write String
out.writeUTF(s);
voidwriteString(DataOutput out, String s)
Writes string to output stream accounting for null values.
out.writeBoolean(s == null);
if (s != null)
    out.writeUTF(s);
voidwriteString(DataOutput out, String s)
write String
if (s != null) {
    byte[] buffer = s.getBytes("UTF-8");
    int len = buffer.length;
    out.writeInt(len);
    out.write(buffer, 0, len);
} else {
    out.writeInt(-1);
voidwriteString(DataOutput out, String v)
Writes a String value.
if (v == null) {
    out.writeInt(-1);
} else {
    byte[] ba = v.getBytes("UTF-8");
    int l = ba.length;
    out.writeInt(l);
    if (l > 0)
        out.write(ba, 0, l);
...
voidwriteString(DataOutput output, String s)
write String
byte[] bs = s.getBytes(UTF_8);
writeVInt(output, bs.length);
output.write(bs);
voidwriteString(final String data, final DataOutput out, final int length)
write String
try {
    byte[] bytes = data.getBytes("UTF-8");
    assert bytes.length <= length;
    out.write(bytes);
    if (bytes.length < length)
        out.write(new byte[length - bytes.length]); 
} catch (IOException ioe) {
    throw new Error(ioe);
...
voidwriteString(final String string, final DataOutput out)
write String
if (string == null) {
    out.writeBoolean(true);
} else {
    out.writeBoolean(false);
    out.writeUTF(string);
voidwriteString(String par0Str, DataOutput par1DataOutput)
write String
if (par0Str.length() > 32767) {
    throw new IOException("String too big");
} else {
    par1DataOutput.writeShort(par0Str.length());
    par1DataOutput.writeChars(par0Str);
voidwriteString(String s, DataOutput output)
Write a String to a DataOutput.
output.writeInt(s.length());
output.writeChars(s);