public void encode(File file, OutputStream base64OutputStream) { try { InputStream is = new FileInputStream(file); OutputStream out = new Base64OutputStream(base64OutputStream, 0); Utils.copyStream(is, out); is.close(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }