56 * // Encode a String into bytes
57 * String inputString = "blahblahblah\u20AC\u20AC";
58 * byte[] input = inputString.getBytes("UTF-8");
59 *
60 * // Compress the bytes
61 * byte[] output = new byte[100];
62 * Deflater compresser = new Deflater();
63 * compresser.setInput(input);
64 * compresser.finish();
65 * int compressedDataLength = compresser.deflate(output);
66 *
67 * // Decompress the bytes
68 * Inflater decompresser = new Inflater();
69 * decompresser.setInput(output, 0, compressedDataLength);
70 * byte[] result = new byte[100];
71 * int resultLength = decompresser.inflate(result);
72 * decompresser.end();
73 *
74 * // Decode the bytes into a String
75 * String outputString = new String(result, 0, resultLength, "UTF-8");
76 * } catch(java.io.UnsupportedEncodingException ex) {
77 * // handle
78 * } catch (java.util.zip.DataFormatException ex) {
79 * // handle
80 * }
81 * </pre></blockquote>
82 *
83 * @apiNote
84 * To release resources used by this {@code Inflater}, the {@link #end()} method
85 * should be called explicitly. Subclasses are responsible for the cleanup of resources
86 * acquired by the subclass. Subclasses that override {@link #finalize()} in order
87 * to perform cleanup should be modified to use alternative cleanup mechanisms such
88 * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
89 *
90 * @implSpec
91 * If this {@code Inflater} has been subclassed and the {@code end} method has been
92 * overridden, the {@code end} method will be called by the finalization when the
93 * inflater is unreachable. But the subclasses should not depend on this specific
94 * implementation; the finalization is not reliable and the {@code finalize} method
95 * is deprecated to be removed.
96 *
|
56 * // Encode a String into bytes
57 * String inputString = "blahblahblah\u20AC\u20AC";
58 * byte[] input = inputString.getBytes("UTF-8");
59 *
60 * // Compress the bytes
61 * byte[] output = new byte[100];
62 * Deflater compresser = new Deflater();
63 * compresser.setInput(input);
64 * compresser.finish();
65 * int compressedDataLength = compresser.deflate(output);
66 *
67 * // Decompress the bytes
68 * Inflater decompresser = new Inflater();
69 * decompresser.setInput(output, 0, compressedDataLength);
70 * byte[] result = new byte[100];
71 * int resultLength = decompresser.inflate(result);
72 * decompresser.end();
73 *
74 * // Decode the bytes into a String
75 * String outputString = new String(result, 0, resultLength, "UTF-8");
76 * } catch (java.io.UnsupportedEncodingException ex) {
77 * // handle
78 * } catch (java.util.zip.DataFormatException ex) {
79 * // handle
80 * }
81 * </pre></blockquote>
82 *
83 * @apiNote
84 * To release resources used by this {@code Inflater}, the {@link #end()} method
85 * should be called explicitly. Subclasses are responsible for the cleanup of resources
86 * acquired by the subclass. Subclasses that override {@link #finalize()} in order
87 * to perform cleanup should be modified to use alternative cleanup mechanisms such
88 * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method.
89 *
90 * @implSpec
91 * If this {@code Inflater} has been subclassed and the {@code end} method has been
92 * overridden, the {@code end} method will be called by the finalization when the
93 * inflater is unreachable. But the subclasses should not depend on this specific
94 * implementation; the finalization is not reliable and the {@code finalize} method
95 * is deprecated to be removed.
96 *
|