1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

allow ZipFile to accept InputStreams

This commit is contained in:
MPeter 2022-09-01 21:39:30 +02:00
parent e7bd1620fe
commit 56d087da2f

View File

@ -23,12 +23,20 @@ public class ZipFile implements AutoCloseable {
/** /**
* Open ZIP file from byte array in memory * Open ZIP file from byte array in memory
* @param zipBytes * @param zipBytes data to handle as a ZIP file
*/ */
public ZipFile(byte[] zipBytes) { public ZipFile(byte[] zipBytes) {
zipInputStream = new ZipInputStream(new ByteArrayInputStream(zipBytes)); zipInputStream = new ZipInputStream(new ByteArrayInputStream(zipBytes));
} }
/**
* Open ZIP file from InputStream
* @param inputStream data to handle as a ZIP file
*/
public ZipFile(InputStream inputStream) {
zipInputStream = new ZipInputStream(inputStream);
}
/** /**
* Checks if data resembles a ZIP file.<br> * Checks if data resembles a ZIP file.<br>
* The check is not infallible: it may report self-extracting or other exotic ZIP archives as not a ZIP file, and it may report a corrupted ZIP file as a ZIP file. * The check is not infallible: it may report self-extracting or other exotic ZIP archives as not a ZIP file, and it may report a corrupted ZIP file as a ZIP file.