diff options
author | Doug Zongker <dougz@android.com> | 2010-02-11 13:01:09 -0800 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2010-02-11 14:07:17 -0800 |
commit | 7b402335811a465ee6e520f574e0e9a5cc048380 (patch) | |
tree | 42b3fb7f6ef0df9c1ec4a5960818800eb704818d /common | |
parent | 8b799a323cfc2dfb1c7da18467e21cc4e19504f6 (diff) | |
download | frameworks_base-7b402335811a465ee6e520f574e0e9a5cc048380.zip frameworks_base-7b402335811a465ee6e520f574e0e9a5cc048380.tar.gz frameworks_base-7b402335811a465ee6e520f574e0e9a5cc048380.tar.bz2 |
add NO_CLOSE flag for use by Base64OutputStream
Change-Id: Ib2884e7b3853e4e4b2e329edf47c6f64c2f165a7
Diffstat (limited to 'common')
-rw-r--r-- | common/java/com/android/common/Base64.java | 7 | ||||
-rw-r--r-- | common/java/com/android/common/Base64OutputStream.java | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/common/java/com/android/common/Base64.java b/common/java/com/android/common/Base64.java index 772d567..d65e24e 100644 --- a/common/java/com/android/common/Base64.java +++ b/common/java/com/android/common/Base64.java @@ -51,6 +51,13 @@ public class Base64 { */ public static final int WEB_SAFE = 8; + /** + * Flag to pass to Base64OutputStream to indicate that it should + * not close the output stream it is wrapping when it itself is + * closed. + */ + public static final int NO_CLOSE = 16; + // -------------------------------------------------------- // decoding // -------------------------------------------------------- diff --git a/common/java/com/android/common/Base64OutputStream.java b/common/java/com/android/common/Base64OutputStream.java index 7c37428..76e1b6a 100644 --- a/common/java/com/android/common/Base64OutputStream.java +++ b/common/java/com/android/common/Base64OutputStream.java @@ -29,6 +29,7 @@ public class Base64OutputStream extends FilterOutputStream { private final boolean encode; private final Base64.EncoderState estate; private final Base64.DecoderState dstate; + private final int flags; private byte[] buffer = null; private int bpos = 0; @@ -59,6 +60,7 @@ public class Base64OutputStream extends FilterOutputStream { */ public Base64OutputStream(OutputStream out, int flags, boolean encode) { super(out); + this.flags = flags; this.encode = encode; if (encode) { estate = new Base64.EncoderState(flags, null); @@ -106,7 +108,11 @@ public class Base64OutputStream extends FilterOutputStream { public void close() throws IOException { flushBuffer(); internalWrite(EMPTY, 0, 0, true); - out.close(); + if ((flags & Base64.NO_CLOSE) == 0) { + out.close(); + } else { + out.flush(); + } } /** |