Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base64OutputStream


    private static String encode(List<StageInput> inputList) throws IOException {
        assert inputList != null;
        String[] dictionary = buildDictionary(inputList);
        ByteArrayOutputStream sink = new ByteArrayOutputStream();
        DataOutputStream output = new DataOutputStream(new GZIPOutputStream(new Base64OutputStream(sink)));
        WritableUtils.writeVLong(output, SERIAL_VERSION);
        WritableUtils.writeStringArray(output, dictionary);
        WritableUtils.writeVInt(output, inputList.size());
        for (StageInput input : inputList) {
            writeEncoded(output, dictionary, input.getPathString());
View Full Code Here


                throw new IllegalStateException();
            }
        }
        try {
            ByteArrayOutputStream sink = new ByteArrayOutputStream();
            DataOutputStream output = new DataOutputStream(new GZIPOutputStream(new Base64OutputStream(sink)));
            WritableUtils.writeVLong(output, SERIAL_VERSION);
            WritableUtils.writeVInt(output, specs.size());
            for (OutputSpec spec : specs) {
                WritableUtils.writeString(output, spec.basePath);
                WritableUtils.writeVInt(output, spec.deletePatterns.size());
View Full Code Here

        oos.writeObject(this);
        oos.close();

        ByteArrayOutputStream buf2 = new ByteArrayOutputStream();

        DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
        buf2.write(PREAMBLE);
        dos.writeInt(buf.size());
        buf.writeTo(dos);
        dos.close();
        buf2.write(POSTAMBLE);
View Full Code Here

            raf.setLength(0);
            rafOutputStream = new RandomAccessFileOutputStream(raf);
            if(useBase64){
                raf.write(BASE64_ENCODING);
                //outputStream=new Base64OutputStream(rafOutputStream);
                outputStream=new Base64OutputStream(rafOutputStream, true, 0, null);
                //outputStream.write(BASE64_ENCODING);
            } else {
                raf.write(BINARY_ENCODING);
                outputStream = rafOutputStream;
            }
View Full Code Here

        }
    }
    static public void binFile2base64File(File inputFile, File outputFile) throws FileNotFoundException, IOException{
        FileOutputStream binOut = new FileOutputStream(outputFile);
        FileInputStream in = new FileInputStream(inputFile);
        OutputStream out=new Base64OutputStream(binOut);
        try{
            int nRead;
            byte []binBytes=new byte[1024];
            while(true){
                nRead=in.read(binBytes);
                if(-1==nRead) break;
                out.write(binBytes, 0,nRead);
            }
        } finally{
            out.close();
            in.close();
        }
    }
View Full Code Here

                        cipherOutputStream,
                        cipher, getSecretKey(), getIvLength());
                //buffering seems not to help
                //bufferedOutputStream = new BufferedOutputStream(new Base64OutputStream(ivSplittingOutputStream, false), 8192 * 5);
                ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
                OutputStream base64OutputStream = new Base64OutputStream(replaceableOuputStream, false);
                ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
                OutputStreamWriter outputStreamWriter =
                        new OutputStreamWriter(base64OutputStream, inputProcessorChain.getDocumentContext().getEncoding());

                //read the encrypted data from the stream until an end-element occurs and write then
View Full Code Here

                XMLSecurityConstants.secureRandom.nextBytes(iv);
                IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
                symmetricCipher.init(Cipher.ENCRYPT_MODE, encryptionPartDef.getSymmetricKey(), ivParameterSpec);

                characterEventGeneratorOutputStream = new CharacterEventGeneratorOutputStream();
                Base64OutputStream base64EncoderStream =
                        new Base64OutputStream(characterEventGeneratorOutputStream, true, 0, null);
                base64EncoderStream.write(iv);

                OutputStream outputStream = new CipherOutputStream(base64EncoderStream, symmetricCipher);
                outputStream = applyTransforms(outputStream);
                //the trimmer output stream is needed to strip away the dummy wrapping element which must be added
                cipherOutputStream = new TrimmerOutputStream(outputStream, 8192 * 10, 3, 4);
View Full Code Here

    }

    // Gzip and base64 encode the string for jo
    void writeCompressedJsonToFile(JSONObject jo, File f) throws IOException,
            JSONException {
        OutputStream os = new GZIPOutputStream(new Base64OutputStream(
                new FileOutputStream(f)));
        try {
            OutputStreamWriter w = new OutputStreamWriter(os);
            BufferedWriter b = new BufferedWriter(w);
            jo.write(b);
View Full Code Here

    }

    @Override
    public void convertBase64Binary(XSBinaryPointable binaryp, DataOutput dOut) throws SystemException, IOException {
        baaos.reset();
        Base64OutputStream b64os = new Base64OutputStream(baaos, true);
        b64os.write(binaryp.getByteArray(), binaryp.getStartOffset() + 2, binaryp.getLength() - 2);

        dOut.write(returnTag);
        dOut.write((byte) ((baaos.size() >>> 8) & 0xFF));
        dOut.write((byte) ((baaos.size() >>> 0) & 0xFF));
        dOut.write(baaos.getByteArray(), 0, baaos.size());
View Full Code Here

    }

    @Override
    public void convertString(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException {
        baaos.reset();
        Base64OutputStream b64os = new Base64OutputStream(baaos, false);
        b64os.write(stringp.getByteArray(), stringp.getStartOffset() + 2, stringp.getLength() - 2);

        dOut.write(ValueTag.XS_BASE64_BINARY_TAG);
        dOut.write((byte) ((baaos.size() >>> 8) & 0xFF));
        dOut.write((byte) ((baaos.size() >>> 0) & 0xFF));
        dOut.write(baaos.getByteArray(), 0, baaos.size());
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Base64OutputStream

Copyright © 2018 www.massapicom. 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.