import java.awt.Dimension;
import java.awt.Rectangle;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
* @return the inflated picture data.
*/
private static byte[] inflatePictureData(byte[] data) {
- try (InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
+ try (InflaterInputStream in = new InflaterInputStream(new UnsynchronizedByteArrayInputStream(data));
UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream()) {
IOUtils.copy(in, out);
return out.toByteArray();
package org.apache.poi.poifs.filesystem;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
*/
public static void createOleMarkerEntry(final DirectoryEntry parent) throws IOException {
if (!parent.hasEntry(OLE_MARKER_NAME)) {
- parent.createDocument(OLE_MARKER_NAME, new ByteArrayInputStream(OLE_MARKER_BYTES));
+ parent.createDocument(OLE_MARKER_NAME, new UnsynchronizedByteArrayInputStream(OLE_MARKER_BYTES));
}
}
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
cachedImage = data.clone();
cachedContentType = contentType;
}
- img = readImage(new ByteArrayInputStream(data), contentType);
+ img = readImage(new UnsynchronizedByteArrayInputStream(data), contentType);
}
/**
final InputStream bis;
if (data instanceof ByteArrayInputStream) {
bis = data;
+ } else if (data instanceof UnsynchronizedByteArrayInputStream) {
+ bis = data;
} else {
UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(0x3FFFF);
IOUtils.copy(data, bos);
import java.awt.Dimension;
import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.util.Internal;
public ImageHeaderBitmap(byte[] data, int offset) {
BufferedImage img = null;
try {
- img = ImageIO.read(new ByteArrayInputStream(data, offset, data.length-offset));
+ img = ImageIO.read(new UnsynchronizedByteArrayInputStream(data, offset, data.length-offset));
} catch (IOException e) {
LOG.atWarn().withThrowable(e).log("Can't determine image dimensions");
}
package org.apache.poi.sl.image;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.RecordFormatException;
public byte[] extractPNG() {
//
//Just cut it off!.
- try (InputStream is = new ByteArrayInputStream(data)) {
+ try (InputStream is = new UnsynchronizedByteArrayInputStream(data)) {
if (is.skip(MAGIC_OFFSET) == MAGIC_OFFSET && FileMagic.valueOf(is) == FileMagic.PNG) {
return IOUtils.toByteArray(is);
}