< prev index next >

src/java.base/share/classes/java/util/zip/Deflater.java

Print this page
8203328: Rename EFS in java.util.zip internals to something meaningful
Reviewed-by: sherman


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




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


< prev index next >