/** * Method used for encode the file to base64 binary format * @param file * @return encoded file format */ private String encodeFileToBase64Binary(File file){ String encodedfile = null; try { FileInputStream fileInputStreamReader = new FileInputStream(file); byte[] bytes = new byte[(int)file.length()]; fileInputStreamReader.read(bytes); encodedfile = Base64.encodeBase64(bytes).toString(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return encodedfile; }
This solution works for me. thanx…
Don’t work for files large!
Please help