• Post Reply Bookmark Topic Watch Topic
  • New Topic

calculate size of output from HttpServletResponse  RSS feed

 
chenfan cia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, i want to know how to calculate size (in bytes) of the output from HttpServletResponse.

example:
if I have an output of "abc" in my jsp,
it will result of 3.

can I use this:

DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.size();

thanks in advance..
I'm sorry if this question not related in this topic
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
size()
Returns the current value of the counter written, the number of bytes written to this data output stream so far.


So, if you write your output to 'dos', then it will be counted by the DataOutputStream

eg
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.writeChars("abc");
int len = dos.size();
 
chenfan cia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks..
it works..
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
phew
(I need a 'wipe the forehead' icon )
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!