blob: d263578e010c79f627bfba1970586665bce6897e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package org.zwobble.mammoth.internal.docx;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZippedDocxFile implements DocxFile {
private final ZipFile zipFile;
public ZippedDocxFile(ZipFile zipFile) {
this.zipFile = zipFile;
}
@Override
public Optional<InputStream> tryGetInputStream(String name) throws IOException {
ZipEntry entry = zipFile.getEntry(name);
if (entry == null) {
return Optional.empty();
} else {
return Optional.of(zipFile.getInputStream(entry));
}
}
@Override
public void close() throws IOException {
zipFile.close();
}
}
|