If I call writeUTF(String) on a DataOutput object, is there a way to tell how many bytes were actually written?
E.g.:
public int write(DataOutput output) throws IOException {
output.writeUTF(this.messageString);
int numberOfBytesWritten = ???;
return numberOfBytesWritten;
}
The only method that comes to mind is to create a DataOutputStream, write the string to that and check the size, then rewrite the string to the actual output. But that seems inefficient.