diff options
author | Nico Kruber <[email protected]> | 2013-01-28 20:05:24 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-02-04 09:52:34 +0100 |
commit | 283569b8ede00003c24776961e77051f37dc5594 (patch) | |
tree | 4c6c2d9ef9c2d548c346f210a69b9deeea87c427 /lib/jinterface/java_src/com | |
parent | d78f2ee3f2bd9ce38d77d70c0893e16b9d0f8df4 (diff) | |
download | otp-283569b8ede00003c24776961e77051f37dc5594.tar.gz otp-283569b8ede00003c24776961e77051f37dc5594.tar.bz2 otp-283569b8ede00003c24776961e77051f37dc5594.zip |
jinterface, OtpOutputStream: add a write_compressed(object, level) method
Now that we use an own deflater, we can also allow the user to specify the compression level as in Erlang's term_to_binary/2.
Diffstat (limited to 'lib/jinterface/java_src/com')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java index 884a0cd21c..f7d5891a27 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java @@ -796,11 +796,23 @@ public class OtpOutputStream extends ByteArrayOutputStream { /** * Write an arbitrary Erlang term to the stream in compressed format. - * + * * @param o - * the Erlang tem to write. + * the Erlang term to write. */ public void write_compressed(final OtpErlangObject o) { + write_compressed(o, Deflater.DEFAULT_COMPRESSION); + } + + /** + * Write an arbitrary Erlang term to the stream in compressed format. + * + * @param o + * the Erlang term to write. + * @param level + * the compression level (<tt>0..9</tt>) + */ + public void write_compressed(final OtpErlangObject o, int level) { final OtpOutputStream oos = new OtpOutputStream(o); /* * similar to erts_term_to_binary() in external.c: @@ -825,7 +837,7 @@ public class OtpOutputStream extends ByteArrayOutputStream { // -> if compression uses more, use the uncompressed term! int destCount = startCount + oos.size(); this.fixedSize = destCount; - Deflater def = new Deflater(); + Deflater def = new Deflater(level); final java.util.zip.DeflaterOutputStream dos = new java.util.zip.DeflaterOutputStream( this, def); try { |