Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package teste; import org.apache.commons.codec.binary.Base64; /** * * @author daniel */ public class transformarImage { public static String encodeImage(byte[] imageByteArray) { return Base64.encodeBase64URLSafeString(imageByteArray); } /** * Decodes the base64 string into byte array * @param imageDataString - a {@link java.lang.String} * @return byte array */ public static byte[] decodeImage(String imageDataString) { return Base64.decodeBase64(imageDataString); } }