[bug-69628] make ZipArchiveFakeEntry.setMaxEntrySize publicly accessible

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1924593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-03-25 16:08:59 +00:00
parent a076204fac
commit d8a2bbb900
2 changed files with 22 additions and 1 deletions

View File

@ -35,7 +35,7 @@ import org.apache.poi.util.TempFile;
* close this as soon as you can!
* @see ZipInputStreamZipEntrySource#setThresholdBytesForTempFiles(int)
*/
/* package */ class ZipArchiveFakeEntry extends ZipArchiveEntry implements Closeable {
public final class ZipArchiveFakeEntry extends ZipArchiveEntry implements Closeable {
private static final Logger LOG = PoiLogManager.getLogger(ZipArchiveFakeEntry.class);
// how large a single entry in a zip-file should become at max

View File

@ -208,6 +208,27 @@ public final class IOUtils {
return toByteArray(stream, length, maxLength, true, length != Integer.MAX_VALUE);
}
/**
* Reads up to {@code length} bytes from the input stream, and returns the bytes read.
*
* @param stream The byte stream of data to read.
* @param length The maximum length to read, use {@link Integer#MAX_VALUE} to read the stream
* until EOF
* @param maxLength if the input is equal to/longer than {@code maxLength} bytes,
* then throw an {@link IOException} complaining about the length.
* use {@link Integer#MAX_VALUE} to disable the check - if {@link #setByteArrayMaxOverride(int)} is
* set then that max of that value and this maxLength is used
* @return A byte array with the read bytes.
* @throws IOException If reading data fails or EOF is encountered too early for the given length.
* @throws RecordFormatException If the requested length is invalid.
* @since POI 5.4.1
*/
public static byte[] toByteArray(InputStream stream, final long length, final int maxLength) throws IOException {
return toByteArray(stream,
length > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) length,
maxLength, true, length != Integer.MAX_VALUE);
}
/**
* Reads the input stream, and returns the bytes read.
*