Example usage for org.apache.commons.codec.binary Base64 encodeBase64Chunked

List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64Chunked

Introduction

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

Prototype

public static byte[] encodeBase64Chunked(final byte[] binaryData) 

Source Link

Document

Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks

Usage

From source file:pt.lsts.neptus.util.ByteUtil.java

public static void main(String[] args) {
    dumpAsHex("Teste", "Isto  de facto \0 um teste para ver se imprime bem Hex!".getBytes(), System.out);

    dumpAsHex(FileUtil.getFileAsString("LICENSE.md").getBytes(), System.out);

    String fxImg = FileUtil.getResourceAsFileKeepName("images/auto-pilot.png");
    dumpAsHex(FileUtil.getFileAsString(fxImg).getBytes(), System.out);

    String tt = "\0\1Isto  de facto um teste para ver se imprime bem Hex!";
    tt = FileUtil.getFileAsString("LICENSE.md");
    System.out.println(new String(Base64.encodeBase64Chunked(tt.getBytes())));
    //dumpAsHex(tt.getBytes(), System.out);

    System.out.println(new String(Base64.decodeBase64(Base64.encodeBase64Chunked(tt.getBytes()))));

    System.err.println(dumpAsHexToString(FileUtil.getFileAsString("LICENSE.md").getBytes()));
}

From source file:pt.up.fe.dceg.neptus.util.ByteUtil.java

public static void main(String[] args) {
    dumpAsHex("Teste", "Isto  de facto \0 um teste para ver se imprime bem Hex!".getBytes(), System.out);

    dumpAsHex(FileUtil.getFileAsString("legal/Neptus-LICENSE.txt").getBytes(), System.out);

    dumpAsHex(FileUtil.getFileAsString("src/images/auto-pilot.png").getBytes(), System.out);

    String tt = "\0\1Isto  de facto um teste para ver se imprime bem Hex!";
    tt = FileUtil.getFileAsString("legal/Neptus-LICENSE.txt");
    NeptusLog.pub().info("<###> " + new String(Base64.encodeBase64Chunked(tt.getBytes())));
    //dumpAsHex(tt.getBytes(), System.out);

    NeptusLog.pub().info("<###> " + new String(Base64.decodeBase64(Base64.encodeBase64Chunked(tt.getBytes()))));

    System.err.println(dumpAsHexToString(FileUtil.getFileAsString("legal/Neptus-LICENSE.txt").getBytes()));

}

From source file:uk.chromis.pos.util.Base64Encoder.java

/**
 *
 * @param raw//from   w  w  w .  ja v a 2  s  . c  om
 * @return
 */
public static String encodeChunked(byte[] raw) {
    try {
        return new String(Base64.encodeBase64Chunked(raw), "ASCII");
    } catch (UnsupportedEncodingException e) {
        return null;
    }
}