Example usage for org.apache.commons.codec.binary Base64Codec encodeBase64String

List of usage examples for org.apache.commons.codec.binary Base64Codec encodeBase64String

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Base64Codec encodeBase64String.

Prototype

public static String encodeBase64String(byte[] binaryData) 

Source Link

Document

Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF.

Usage

From source file:com.googlecode.android_scripting.facade.BluetoothFacade.java

@Rpc(description = "Read up to bufferSize bytes and return a chunked, base64 encoded string.")
public String bluetoothReadBinary(@RpcParameter(name = "bufferSize") @RpcDefault("4096") Integer bufferSize,
        @RpcParameter(name = "connID", description = "Connection id") @RpcDefault("") @RpcOptional String connID)
        throws IOException {

    BluetoothConnection conn = getConnection(connID);
    try {//w  w w  .jav a 2  s.  com
        return Base64Codec.encodeBase64String(conn.readBinary(bufferSize));
    } catch (IOException e) {
        connections.remove(conn.getUUID());
        throw e;
    }
}

From source file:com.googlecode.android_scripting.facade.bluetooth.BluetoothSocketConnFacade.java

/**
 * Read up to bufferSize bytes and return a chunked, base64 encoded string
 *
 * @param bufferSize the size of buffer to read
 * @param connID the connection ID//w w  w.  ja va  2  s  .co m
 * @return the string buffer containing the read base64-encoded characters
 * @throws Exception
 */
@Rpc(description = "Read up to bufferSize bytes and return a chunked, base64 encoded string.")
public String bluetoothSocketConnReadBinary(
        @RpcParameter(name = "bufferSize") @RpcDefault("4096") Integer bufferSize,
        @RpcParameter(name = "connID", description = "Connection id") @RpcDefault("") @RpcOptional String connID)
        throws IOException {

    BluetoothConnection conn = getConnection(connID);
    try {
        return Base64Codec.encodeBase64String(conn.readBinary(bufferSize));
    } catch (IOException e) {
        mConnections.remove(conn.getUUID());
        throw e;
    }
}

From source file:com.googlecode.android_scripting.facade.USBHostSerialFacade.java

/**
 * usbserialReadBinary: {{{1// w  w w . j av a  2  s.  co m
 */
@Rpc(description = "Read up to bufferSize bytes and return a chunked, base64 encoded string.")
public String usbserialReadBinary(@RpcParameter(name = "bufferSize") @RpcDefault("4096") Integer bufferSize,
        @RpcParameter(name = "connID", description = "Connection id") @RpcDefault("") @RpcOptional String connID)
        throws IOException {

    UsbSerialConnection conn = getConnection(connID);
    try {
        return Base64Codec.encodeBase64String(conn.readBinary(bufferSize));
    } catch (IOException e) {
        removeConnection(conn);
        throw e;
    }
}