8303923: ZipOutStream::putEntry should include an apiNote to indicate that the STORED compression method should be used when writing directory entries
Reviewed-by: lancea, alanb
This commit is contained in:
parent
2bbbff209d
commit
425ef0685c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -191,6 +191,21 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
|
||||
* <p>
|
||||
* The current time will be used if the entry has no set modification time.
|
||||
*
|
||||
* @apiNote When writing a directory entry, the STORED compression method
|
||||
* should be used and the size and CRC-32 values should be set to 0:
|
||||
*
|
||||
* {@snippet lang = "java":
|
||||
* ZipEntry e = new ZipEntry(entryName);
|
||||
* if (e.isDirectory()) {
|
||||
* e.setMethod(ZipEntry.STORED);
|
||||
* e.setSize(0);
|
||||
* e.setCrc(0);
|
||||
* }
|
||||
* stream.putNextEntry(e);
|
||||
*}
|
||||
*
|
||||
* This allows optimal performance when processing directory entries.
|
||||
*
|
||||
* @param e the ZIP entry to be written
|
||||
* @throws ZipException if a ZIP format error has occurred
|
||||
* @throws IOException if an I/O error has occurred
|
||||
|
Loading…
Reference in New Issue
Block a user