|
Hi
!!
I got the answer, the difficulty is to get the resulting XML in
memory to then be able to gzip it
I use
a ByteArrayOutputStream to get it in memory, then I read the array with a
ByteArrayInputStream.
I hope
it will work for you too ;-)
//
Source code
OutputStream out = null;
out =
new FileOutputStream("myfile.svgz");
ByteArrayOutputStream out2 = new
ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out2,"ISO-8859-1"); SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx,
false);
chart.draw(svgGenerator, new Rectangle2D.Double(0, 0, 500, 400), null); svgGenerator.stream(writer, false); ByteArrayInputStream bai = new
ByteArrayInputStream(out2.toString().getBytes());
BufferedInputStream bis = new BufferedInputStream( bai ); GZIPOutputStream gzos = new GZIPOutputStream(new BufferedOutputStream(out)); byte b[] = new byte[4096]; int c = 0; while
((c = bis.read(b)) != -1)
{ gzos.write(b, 0, c); } gzos.finish(); gzos.close(); out.close();
|
Title: Message
