If you use writeObject(String) you won't have a limit problem.
writeUTF still using a short on the beggining of a string identifying its size (from DataOutputSomewhere)
On ObjectOUtputStram.writeObject it's done a check on the size of the string, and a flag it's used to defined if it's a small or a big string.
In JavaOutputStream strings are treated without any metadata check, so you wouldn't have a problem calling wirteObject(String) to write these big strings.
If you still want to write a chuncks of String, I had to write my own UTF parser, and on StringUtil@JBossSerialization I can also write smalls or big strings:
I will be using JBoss Serialization for this, so how would writeObject(String) compare (in terms of size of byte stream) to using writeUTF()?
It will send something like this:
It's very similar to ObjectOutputStream from Java Serialization.
If you want to save 4 bytes from ObjectID you could use StringUtil directly.
So using StringUtil, I would use StringUtil.saveString(DataOutput, String) and this will write:
What are the limitations here, then? The largest String would be 2^32 bytes long, i.e., 4GB?
It is actually:
boolean byte (is BigString)
short size if (short String) or long size if (Big String)
bytes for Strings...
it should be integer, but I'm already using long (if big strings)
If you use StringUtil.. use
StringUtil.readString(dataInput,null); (I was supposed to create an overload here, but null will work here)
If you want/need to move the class to some common project, I'm fine with that.