Johan Compagner wrote:
Maybe i can improve it even more by just doing that encoding
conversion earlier (so not after the redirect but before the redirect
and only store the byte[]
that could be cheaper :) for strings that only take most of the time 1
byte)
Yep, that's absolutely better.
A
i am a bit afraid for using that method that way...
Because that could be pretty heavy.. Encoding is not a cheap operation
and it will generate a byte array that also can be very big.
And then suddenly if we still use PrintWriter we are encoding it twice...
Maybe we should do this:
byte[] byte
that is something the PrintWriter does for you.
But i don't know if i am willing to first generate a complete byte[] of
that string to get the length
and then get the Writer and print the stream..
Maybe there is some tool like:
strings.calculateSize(string, encoding)
That runs through all t
Jan Bares wrote:
You cannot calculate size of the string in bytes? I am not Java
expert, but this must be easy.
Size of the string in bytes is string.getBytes(encoding).length;
Most frameworks don't set the content length, even if it's really bad
for http keep-alive.
Janne
-