package org.apache.poi.hpsf;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.List;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
* @throws IOException if an I/O exception occurs.
*/
public InputStream toInputStream() throws WritingNotSupportedException, IOException {
- return new ByteArrayInputStream(toBytes());
+ return new UnsynchronizedByteArrayInputStream(toBytes());
}
/**
*/
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianOutput;
}
private static RecordInputStream bytesToRIStream(byte[] data) {
- RecordInputStream ric = new RecordInputStream(new ByteArrayInputStream(data));
+ RecordInputStream ric = new RecordInputStream(new UnsynchronizedByteArrayInputStream(data));
ric.nextRecord();
return ric;
}
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
+
import java.util.Map;
import java.util.function.Supplier;
{
byte[] data = r.serialize();
RecordInputStream rinp = new RecordInputStream(
- new ByteArrayInputStream(data)
+ new UnsynchronizedByteArrayInputStream(data)
);
rinp.nextRecord();
return rinp;
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.formula.ptg.Area3DPtg;
}
private static Ptg readRefPtg(byte[] formulaRawBytes) {
- LittleEndianInput in = new LittleEndianInputStream(new ByteArrayInputStream(formulaRawBytes));
+ LittleEndianInput in = new LittleEndianInputStream(new UnsynchronizedByteArrayInputStream(formulaRawBytes));
byte ptgSid = in.readByte();
switch(ptgSid) {
case AreaPtg.sid: return new AreaPtg(in);
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
-
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.util.GenericRecordJsonWriter;
// Do it via a re-serialization
// It's a cheat, but it works...
byte[] b = serialize();
- RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b));
+ RecordInputStream rinp = new RecordInputStream(new UnsynchronizedByteArrayInputStream(b));
rinp.nextRecord();
Record[] r = RecordFactory.createRecord(rinp);
package org.apache.poi.hssf.usermodel;
import java.awt.Dimension;
-import java.io.ByteArrayInputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherBlipRecord;
EscherBSERecord bse = iwb.getBSERecord(getPictureIndex());
byte[] data = bse.getBlipRecord().getPicturedata();
int type = bse.getBlipTypeWin32();
- return ImageUtils.getImageDimension(new ByteArrayInputStream(data), type);
+ return ImageUtils.getImageDimension(new UnsynchronizedByteArrayInputStream(data), type);
}
/**
import static org.apache.poi.hssf.model.InternalWorkbook.WORKBOOK_DIR_ENTRY_NAMES;
import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.regex.Pattern;
import org.apache.commons.codec.digest.DigestUtils;
+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;
DocumentNode workbookNode = (DocumentNode) dir.getEntry(
getWorkbookDirEntryName(dir));
POIFSDocument workbookDoc = new POIFSDocument(workbookNode);
- workbookDoc.replaceContents(new ByteArrayInputStream(getBytes()));
+ workbookDoc.replaceContents(new UnsynchronizedByteArrayInputStream(getBytes()));
// Update the properties streams in the file
writeProperties();
List<String> excepts = new ArrayList<>(1);
// Write out the Workbook stream
- fs.createDocument(new ByteArrayInputStream(getBytes()), "Workbook");
+ fs.createDocument(new UnsynchronizedByteArrayInputStream(getBytes()), "Workbook");
// Write out our HPFS properties, if we have them
writeProperties(fs, excepts);
package org.apache.poi.poifs.filesystem;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.property.DocumentProperty;
}
// Have an empty one created for now
- return parent.createDocument(name, new ByteArrayInputStream(new byte[0]));
+ return parent.createDocument(name, new UnsynchronizedByteArrayInputStream(new byte[0]));
}
private void checkBufferSize() throws IOException {
import static org.apache.poi.util.StringUtil.endsWithIgnoreCase;
import static org.apache.poi.util.StringUtil.startsWithIgnoreCase;
-import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+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;
} else {
// Decompress a previously found module and store the decompressed result into module.buf
InputStream stream = new RLEDecompressingInputStream(
- new ByteArrayInputStream(module.buf, moduleOffset, module.buf.length - moduleOffset)
+ new UnsynchronizedByteArrayInputStream(module.buf, moduleOffset, module.buf.length - moduleOffset)
);
module.read(stream);
stream.close();
}
if (decompressedBytes != null) {
- module.read(new ByteArrayInputStream(decompressedBytes));
+ module.read(new UnsynchronizedByteArrayInputStream(decompressedBytes));
}
}
if (w <= 0 || (w & 0x7000) != 0x3000) {
continue;
}
- decompressed = tryToDecompress(new ByteArrayInputStream(compressed, i, compressed.length - i));
+ decompressed = tryToDecompress(new UnsynchronizedByteArrayInputStream(compressed, i, compressed.length - i));
if (decompressed != null) {
if (decompressed.length > 9) {
//this is a complete hack. The challenge is that there
import java.awt.Dimension;
import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
// in pixel
final Dimension imgSize = (scaleX == Double.MAX_VALUE || scaleY == Double.MAX_VALUE)
- ? getImageDimension(new ByteArrayInputStream(data.getData()), data.getPictureType())
+ ? getImageDimension(new UnsynchronizedByteArrayInputStream(data.getData()), data.getPictureType())
: new Dimension();
// in emus
Dimension imgSize = null;
if (anchor.getCol2() < anchor.getCol1() || anchor.getRow2() < anchor.getRow1()) {
PictureData data = picture.getPictureData();
- imgSize = getImageDimension(new ByteArrayInputStream(data.getData()), data.getPictureType());
+ imgSize = getImageDimension(new UnsynchronizedByteArrayInputStream(data.getData()), data.getPictureType());
}
int w = getDimFromCell(imgSize == null ? 0 : imgSize.getWidth(), anchor.getCol1(), anchor.getDx1(), anchor.getCol2(), anchor.getDx2(),
package org.apache.poi.util;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
+import org.apache.commons.io.input.UnsynchronizedByteArrayInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
/**
public static byte[] decompress(byte[] compressed, int offset, int length) throws IOException {
try (UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream();
- InputStream instream = new ByteArrayInputStream(compressed, offset, length);
- InputStream stream = new RLEDecompressingInputStream(instream)) {
+ InputStream instream = new UnsynchronizedByteArrayInputStream(compressed, offset, length);
+ InputStream stream = new RLEDecompressingInputStream(instream)) {
IOUtils.copy(stream, out);
return out.toByteArray();