+ /**
+ * Convert the given {@link File} image into a Base64 representation of the
+ * same {@link File}.
+ *
+ * @param file
+ * the {@link File} image to convert
+ *
+ * @return the Base64 representation
+ *
+ * @throws IOException
+ * in case of IO error
+ */
+ static public String fromImage(File file) throws IOException {
+ String fileString = null;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ byte[] buf = new byte[8192];
+ InputStream in = new FileInputStream(file);
+
+ int c = 0;
+ while ((c = in.read(buf, 0, buf.length)) > 0) {
+ out.write(buf, 0, c);
+ }
+ out.flush();
+ in.close();
+
+ fileString = DatatypeConverter.printBase64Binary(out.toByteArray());
+ out.close();
+
+ return fileString;
+ }
+