private byte[] getDebugBytes() throws IOException { if (duplicateStream != null) { duplicateStream.flush(); return ((ByteArrayOutputStream) (duplicateStream.getOutputStream())).toByteArray(); } else { return null; } }
@SuppressWarnings("unused") private byte[] getSerializedBytes() { ByteArrayOutputStream bos = null; ObjectOutputStream oos = null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(this); oos.flush(); return bos.toByteArray(); } catch (Exception e) { Logger logger = LoggerFactory.getLogger(PdfDocument.class); logger.warn(LogMessageConstant.DOCUMENT_SERIALIZATION_EXCEPTION_RAISED, e); return null; } finally { if (oos != null) { try { oos.close(); } catch (IOException ignored) { } } if (bos != null) { try { bos.close(); } catch (IOException ignored) { } } } }
/** * Load data by URL. url must be not null. * Note, this method doesn't check if data or url is null. * @throws java.io.IOException */ void loadData() throws java.io.IOException { InputStream input = null; try { input = UrlUtil.openStream(url); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(UrlUtil.openStream(url), stream); data = stream.toByteArray(); } finally { if (input != null) { input.close(); } } } }
/** * Load data by URL. url must be not null. * Note, this method doesn't check if data or url is null. * @throws java.io.IOException */ void loadData() throws java.io.IOException { InputStream input = null; try { input = UrlUtil.openStream(url); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(UrlUtil.openStream(url), stream); data = stream.toByteArray(); } finally { if (input != null) { input.close(); } } } }
/** * Load data from URL. url must be not null. * Note, this method doesn't check if data or url is null. * @throws java.io.IOException */ void loadData() throws java.io.IOException { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(url)); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(raf, stream); raf.close(); data = stream.toByteArray(); }
/** * Load data from URL. url must be not null. * Note, this method doesn't check if data or url is null. * @throws java.io.IOException */ void loadData() throws java.io.IOException { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(url)); ByteArrayOutputStream stream = new ByteArrayOutputStream(); StreamUtil.transferBytes(raf, stream); raf.close(); data = stream.toByteArray(); }
RawImageHelper.updateRawImageParameters(png.image, png.width, png.height, components, bpc, png.idat.toByteArray()); png.image.setDeflated(true); Map<String, Object> decodeparms = new HashMap<>();
RawImageHelper.updateRawImageParameters(png.image, png.width, png.height, components, bpc, png.idat.toByteArray()); png.image.setDeflated(true); Map<String, Object> decodeparms = new HashMap<>();
try { outputStream.getOutputStream().flush(); bytes = ((ByteArrayOutputStream) outputStream.getOutputStream()).toByteArray(); if (decoded && containsKey(PdfName.Filter)) { bytes = PdfReader.decodeBytes(bytes, this);
else if (png.genBWMask) png.smask = new byte[(png.width + 7) / 8 * png.height]; ByteArrayInputStream bai = new ByteArrayInputStream(png.idat.toByteArray()); png.dataStream = FilterUtil.getInflaterInputStream(bai);
else if (png.genBWMask) png.smask = new byte[(png.width + 7) / 8 * png.height]; ByteArrayInputStream bai = new ByteArrayInputStream(png.idat.toByteArray()); png.dataStream = FilterUtil.getInflaterInputStream(bai);
} else { zip.close(); RawImageHelper.updateRawImageParameters(tiff.image, w, h, samplePerPixel - extraSamples, bitsPerSample, stream.toByteArray()); tiff.image.setDeflated(true); mzip.close(); RawImageData mimg = (RawImageData) ImageDataFactory.createRawImage(null); RawImageHelper.updateRawImageParameters(mimg, w, h, 1, bitsPerSample, mstream.toByteArray()); mimg.makeMask(); mimg.setDeflated(true);
} else { zip.close(); RawImageHelper.updateRawImageParameters(tiff.image, w, h, samplePerPixel - extraSamples, bitsPerSample, stream.toByteArray()); tiff.image.setDeflated(true); mzip.close(); RawImageData mimg = (RawImageData) ImageDataFactory.createRawImage(null); RawImageHelper.updateRawImageParameters(mimg, w, h, 1, bitsPerSample, mstream.toByteArray()); mimg.makeMask(); mimg.setDeflated(true);