Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Size of Compressed Data?

 
ram ragu
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
posted October 03, 2002 01:16 PM
--------------------------------------------------------------------------------
Hello,
I compress data using GZIPOutputStream. Is there any way to find out the size of the compressed data?
here is what I do
sb ( StringBuffer )has some data...

GZIPOutputStream gzos =
new GZIPOutputStream(response.getOutputStream());
gzos.write(sb.toString().getBytes());
gzos.close();
Kindly let me know.. I need to find out how good the compression is..
Ram
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write it to a file and look at the file size?
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a ByteArrayOutputStream, "Baos".
Use "Baos" in the ctor of the GZIPOutputStream, "gzip".
Use the .write() method of the "gzip" object.
When done writing to gzip object say "Baos.size()". That is the size of your compressed data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic