Package org.apache.commons.codec.binary

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


            Configuration conf,
            String encoded) throws IOException, ClassNotFoundException {
        assert conf != null;
        assert encoded != null;
        ByteArrayInputStream source = new ByteArrayInputStream(encoded.getBytes(ASCII));
        DataInputStream input = new DataInputStream(new GZIPInputStream(new Base64InputStream(source)));
        long version = WritableUtils.readVLong(input);
        if (version != SERIAL_VERSION) {
            throw new IOException(MessageFormat.format(
                    "Invalid StageInput version: framework={0}, saw={1}",
                    SERIAL_VERSION,
View Full Code Here


            return Collections.emptyList();
        }
        VariableTable table = getVariableTable(context);
        try {
            ByteArrayInputStream source = new ByteArrayInputStream(encoded.getBytes(ASCII));
            DataInputStream input = new DataInputStream(new GZIPInputStream(new Base64InputStream(source)));
            long version = WritableUtils.readVLong(input);
            if (version != SERIAL_VERSION) {
                throw new IOException(MessageFormat.format(
                        "Invalid StageOutput version: framework={0}, saw={1}",
                        SERIAL_VERSION,
View Full Code Here

                byte []dataBytes=new byte[dataBytesBufferSize];
                try{
                    InputStream inputStream;
                    {
                        BufferedInputStream bis = new BufferedInputStream(fis);
                        inputStream = header.isBase64() ? new Base64InputStream(bis): bis;
                    }
                    try{
                        long nSkip;
                        long toSkip=header.getHeaderSize();
                        while((nSkip=fis.skip(toSkip))!=toSkip){
View Full Code Here

        //InputStream inputStream;
        try{
            int firstByte=inputStream.read();
            boolean base64;
            if(firstByte==BASE64_ENCODING){
                in64=new Base64InputStream(inputStream);//base64 decode
                inputStream=in64;
                base64=true;
            }else if(firstByte==BINARY_ENCODING){
                //inputStream=in;
                base64=false;
View Full Code Here

    }

    static public void appendBinFile(OutputStream out, File inputFile, boolean enc64, boolean dec64) throws FileNotFoundException, IOException {
        BufferedOutputStream bout=new BufferedOutputStream(out);
        FileInputStream in=new FileInputStream(inputFile);
        Base64InputStream in64=new Base64InputStream(in, enc64);
        InputStream input = (enc64^dec64) ? in64 : in;
        byte buf[]=new byte[4096];
        byte outBuf[]=buf;
        int read=input.read(buf);
        while(read!=-1){
View Full Code Here

        }
    }*/
    static void base64File2HexFile(File inputFile, File outputFile) throws IOException {
        FileWriter writer = new FileWriter(outputFile);
        FileInputStream inBin = new FileInputStream(inputFile);
        InputStream in=new Base64InputStream(inBin);//base64 decode
        int byteCnt=0;
        String endl=AStringUtilities.systemNewLine;
        try{
            while(true){
                int bin=in.read();
                if(-1==bin)
                    break;
                String hex=AStringUtilities.byteToHex(bin);
                //System.out.println(hex);
                writer.write(hex);
                byteCnt++;
                if(16==byteCnt){
                    byteCnt=0;
                    writer.write(endl);
                }
            }
        } finally{
            writer.close();
            in.close();
        }
    }
View Full Code Here

    if (httpResponse != null) {
      String content = "";
      if (httpResponse.getContentLength() > 0) {
        // Stream out the base64-encoded data.
        // Ctor args indicate to encode w/o line breaks.
        Base64InputStream b64input =
            new Base64InputStream(httpResponse.getResponse(), true, 0, null);
        content = IOUtils.toString(b64input);
      }

      ImmutableList.Builder<GadgetsHandlerApi.NameValuePair> headersBuilder =
          ImmutableList.builder();
View Full Code Here

    if (httpResponse != null) {
      String content = "";
      if (httpResponse.getContentLength() > 0) {
        // Stream out the base64-encoded data.
        // Ctor args indicate to encode w/o line breaks.
        Base64InputStream b64input =
            new Base64InputStream(httpResponse.getResponse(), true, 0, null);
        content = IOUtils.toString(b64input);
      }

      ImmutableList.Builder<GadgetsHandlerApi.NameValuePair> headersBuilder =
          ImmutableList.builder();
View Full Code Here

    pw.write(",");
    pw.flush();

    // Stream out the base64-encoded data.
    // Ctor args indicate to encode w/o line breaks.
    Base64InputStream b64input = new Base64InputStream(response.getResponse(), true, 0, null);
    byte[] buf = new byte[1024];

    try {
      int read;
      while (( read = b64input.read(buf, 0, 1024)) > 0) {
        os.write(buf, 0, read);
      }
    } finally {
      IOUtils.closeQuietly(b64input);
    }
View Full Code Here

        stream.flush();
    }

    @Override
    public Object unmarshal(Exchange exchange, InputStream input) throws Exception {
        return new Base64InputStream(input, false, lineLength, lineSeparator);
    }
View Full Code Here

TOP

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

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.