Package org.apache.commons.io.output

Examples of org.apache.commons.io.output.ByteArrayOutputStream.toByteArray()


        int afph = mpts2units(h);
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        try {
            //Serialize image
            writeImage(bi, baout);
            byte[] buf = baout.toByteArray();

            //Generate image
            ImageObject io = _afpDataStream.getImageObject(afpx, afpy, afpw, afph);
            io.setImageParameters(
                resolution, resolution,
View Full Code Here


        imageEncodingHelperBGR.encode(baosBGR);

        ByteArrayOutputStream baosRGB = new ByteArrayOutputStream();
        imageEncodingHelperRGB.encode(baosRGB);

        assertTrue(Arrays.equals(baosBGR.toByteArray(), baosRGB.toByteArray()));
    }

}
View Full Code Here

        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout);
        Transformer transformer = tFactory.newTransformer();
        Source src = new StreamSource(foFile);
        SAXResult res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
        final byte[] result = baout.toByteArray();
        if (dumpPdfFile) {
            final File outFile = new File(foFile.getParentFile(), foFile.getName() + ".pdf");
            FileUtils.writeByteArrayToFile(outFile, result);
        }
        return result;
View Full Code Here

        //Start the transformation and rendering process
        transformer.transform(src, res);

        //Return the result
        sendPDF(out.toByteArray(), response);
    }
   
    /** @return a new FOUserAgent for FOP */
    protected FOUserAgent getFOUserAgent() {
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
View Full Code Here

                value = 0;
            }
        }
        baout.write(value);
        try {
            cidSet.setData(baout.toByteArray());
            descriptor.setCIDSet(cidSet);
        } catch (IOException ioe) {
            log.error(
                    "Failed to write CIDSet [" + cidFont + "] "
                    + cidFont.getFontName(), ioe);
View Full Code Here

                outputArray[offset++] = (byte) toAscii((j * 16) + k);
            }
            System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset,
                    HexDump.EOL.getBytes().length);
        }
        byte[] actualOutput = stream.toByteArray();

        assertEquals("array size mismatch", outputArray.length,
                actualOutput.length);
        for (int j = 0; j < outputArray.length; j++) {
            assertEquals("array[ " + j + "] mismatch", outputArray[j],
View Full Code Here

                outputArray[offset++] = (byte) toAscii((j * 16) + k);
            }
            System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset,
                    HexDump.EOL.getBytes().length);
        }
        actualOutput = stream.toByteArray();
        assertEquals("array size mismatch", outputArray.length,
                actualOutput.length);
        for (int j = 0; j < outputArray.length; j++) {
            assertEquals("array[ " + j + "] mismatch", outputArray[j],
                    actualOutput[j]);
View Full Code Here

                outputArray[offset++] = (byte) toAscii((j * 16) + k);
            }
            System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset,
                    HexDump.EOL.getBytes().length);
        }
        actualOutput = stream.toByteArray();
        assertEquals("array size mismatch", outputArray.length,
                actualOutput.length);
        for (int j = 0; j < outputArray.length; j++) {
            assertEquals("array[ " + j + "] mismatch", outputArray[j],
                    actualOutput[j]);
View Full Code Here

                }
            }
            System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset,
                    HexDump.EOL.getBytes().length);
        }
        actualOutput = stream.toByteArray();
        assertEquals("array size mismatch", outputArray.length,
                actualOutput.length);
        for (int j = 0; j < outputArray.length; j++) {
            assertEquals("array[ " + j + "] mismatch", outputArray[j],
                    actualOutput[j]);
View Full Code Here

        OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
       
        CopyUtils.copy(inData, out);

        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
    }

    public void testCopy_byteArrayToWriter() throws Exception {
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.